For our next assignment you will be constructing a mobile app with Jetpack Compose that interacts with a back end server that I have set up. The system we will be implementing is a simple email system that allows users to send and receive email messages.
In the notes below I am going to give you a guide to what the back end server can do for you. Your job will be to construct a mobile app that will act as the user interface for the mail system. I will give you some broad requirements for what the app should allow users to do, but I will not provide any specific suggestions on how to set up your user interface.
I have set up a back end server for the mail system at
https://cmsc106.net/mail
The server includes a documentation page at
https://cmsc106.net/mail/swagger-ui/index.html
that you can view in a browser. That documentation page lists every one of the interactions that the server supports. For GET requests the documentation page shows you the structure of the data that the server will return. For POST requests the documentation will show you the structure of the objects that you are expected to send in the body of the POST.
To supplement the information on the documentation page, here is a quick guide to some the things you will want to do with the server.
1. To create a new user on the system you will need to POST an object that takes the form
{
"name": <user name>,
"password": <password>
}
to the URL https://cmsc106.net/mail/user. If the request is successful the server will respond by sending you an object with the structure
{
"userId": <user id>
}
containing a user id for that user. If the user name is already taken the server will respond with a 409 Conflict error code.
2. To log in an existing user send a GET request to the URL
https://cmsc106.net/mail/user?user=<user name>&password=<password>
If the login is successful the server will respond by sending you an object with the structure
{
"userId": <user id>
}
containing a user id for that user. If the login fails the server will respond with a 401 Unauthorized error code.
3. The email system allows you to send emails to multiple recipients. To send an email, start by sending a POST request to https://cmsc106.net/mail/message that has a body that takes the form
{
"subject": <subject>,
"body": <body>,
"sender": <user id>
}
The server will respond by sending you an object with the structure
{
"messageId": <message id>
}
containing a message id for that newly created message For each recipient of the message you will then need to send a POST request to https://cmsc106.net/mail/recipient that has a body that takes the form
{
"message": <message id>,
"recipient": <user name>
}
4. To fetch a list of messages that have been sent to a particular user, send a GET request to
https://cmsc106.net/mail/handles?receiver=<user id>
The server will respond by sending you back an array of objects that take the form
{
"messageId": <message id>,
"receiver": <user id>,
"sender": <user name>,
"subject": <subject>
}
5. To fetch a message send a GET request to the URL
https://cmsc106.net/mail/message/<message id>
The server will send back an object that takes the form
{
"subject": <subject>,
"body": <body>,
"sent": <time stamp>,
"sender": <user name>,
"idmessage": <message id>
}
6. To delete a message you actually remove yourself as a recipient for that message. To do this, send a DELETE request to the URL
https://cmsc106.net/mail/recipient/<user id>/message/<message id>
The mobile app will need to support the following operations:
Here is a suggestion for how to handle viewing messages. Add a click handler to each item in the list of messages that navigates the user to a screen where they can view the details of that message. Equip that screen with two buttons, one to close the message and the other to delete the message. Clicking either of these two buttons should navigate the user back to the screen that displays the list of messages.