Congratulations—you've landed a job with TEBucks, whose product is an online payment service for transferring "TE bucks" between friends. However, they don't have a product yet. You've been tasked with writing a RESTful API server and command-line application.
The frontend of TEBucks has been completed for you, and it is hosted at https://tebucks.netlify.app/ Your job is to complete the backend, including the Web API and database.
The frontend team has provided the API design for you, which can be found further down in the README. You must adhere to this de# order for the frontend to work with your backend. You can and will need to add to the provided models, but do not take away fields that were provided as the frontend relies on these field names and data types.
You should attempt to complete all the following required use cases.
- [COMPLETE] As a user of the system, I need to be able to register myself with a username and password.
- The ability to register has been provided in your starter code.
- [COMPLETE] As a user of the system, I need to be able to log in using my registered username and password.
- Logging in returns an Authentication Token. I need to include this token with all my subsequent interactions with the system outside of registering and logging in.
- The ability to log in has been provided in your starter code.
- A newly registered user should start with an initial balance of 1,000 TE Bucks.
- As an authenticated user of the system, I need to be able to see my Account Balance.
- As an authenticated user of the system, I need to be able to send a transfer of a specific amount of TE Bucks to a registered user.
- I should be able to choose from a list of users to send TE Bucks to.
- A transfer includes the User IDs of the from and to users and the amount of TE Bucks.
- The receiver's account balance is increased by the amount of the transfer.
- The sender's account balance is decreased by the amount of the transfer.
- I can't send more TE Bucks than I have in my account.
- I can't send a zero or negative amount.
- I must not be allowed to send money to myself.
- A Sending Transfer has an initial status of Approved.
- As an authenticated user of the system, I need to be able to see transfers I have sent or received.
- As an authenticated user of the system, I need to be able to retrieve the details of any transfer based upon the transfer ID.
- As an authenticated user of the system, I need to be able to request a transfer of a specific amount of TE Bucks from another registered user.
- I should be able to choose from a list of users to request TE Bucks from.
- I must not be allowed to request money from myself.
- I can't request a zero or negative amount.
- A transfer includes the User IDs of the from and to users and the amount of TE Bucks.
- A Request Transfer has an initial status of Pending.
- No account balance changes until the request is approved.
- The transfer request should appear in both users' list of transfers (use case #7).
- As an authenticated user of the system, I need to be able to see my Pending transfers.
- As an authenticated user of the system, I need to be able to either approve or reject a Request Transfer.
- I can't "approve" a given Request Transfer for more TE Bucks than I have in my account.
- The Request Transfer status is Approved if I approve, or Rejected if I reject the request.
- If the transfer is approved, the requester's account balance is increased by the amount of the request.
- If the transfer is approved, the requestee's account balance is decreased by the amount of the request.
- If the transfer is rejected, no account balance changes.
- As a Tech Elevator Banking System, I need to log specific transactions with the Tech Elevator Aberrant Revenue Service (TEARS).
- Login to TEARS using the
/#
endpoint. This endpoint will return a JWT token, which will be used in all subsequent requests to log information. - I must log any transfer of at least $1,000 TE Bucks or more.
- I must log any transfer attempt that would result in an overdraft.
- Login to TEARS using the
In order to communicate with TEARS, you need to create an account with a username and password. Create your user account for TEARS using PostMan and the registration endpoint /register
, be sure to record your username and password. The full documentation for the TEARS API is located at https://tears.azurewebsites.net/.
In the database folder, you'll find the database creation script tebucks.sql
. Open this in SQL Server Management Studio and execute it.
A Datasource has been configured for you in appsettings.json
.
"ConnectionStrings": {
"Project": "Server=.\\SQLEXPRESS;Database=tebucks;Trusted_Connection=True;"
},
Provided
Request Method | Path | Request Body | Returns |
---|---|---|---|
POST | /# | LoginDto | LoginResponseDto |
POST | /register | RegisterUserDto | void |
For you to complete
Request Method | Path | Request Body | Returns |
---|---|---|---|
GET | /api/account/balance | N/A | Account |
GET | /api/account/transfers | N/A | List<Transfer> |
GET | /api/transfers/{id} | N/A | Transfer |
POST | /api/transfers | NewTransferDto | Transfer |
PUT | /api/transfers/{id}/status | TransferStatusUpdateDto | Transfer |
GET | /api/users | N/A | List<User> |
LoginDto
{
"username" : "A string to hold the user's name",
"password" : "A string containing the password"
}
LoginResponseDto
{
"token" : "A string holding the JWT for the user",
"user" : "An object representing the user"
}
RegisterUserDto
{
"firstname" : "A string to hold the user's first name",
"lastname" : "A string to hold the user's last name",
"username" : "A string to hold the user's name",
"password" : "A string containing the password"
}
Account
{
"accountId" : "An integer holding the account id",
"userId" : "An integer holding the user's id",
"balance" : "An decimal holding the account balance"
}
Transfer
{
"transferId" : "An integer holding the transfer id",
"transferType" : "A string for the transfer type: Send or Request",
"transferStatus" : "A string for the transer status: Pending, Approved, or Rejected",
"userFrom" : "A user object representing the user who is transfering the money",
"userTo" : "A user object representing the user who receiving the transfered money",
"amount" : "A decimal indicating the amount to transfer"
}
NewTransferDto
{
"userFrom" : "An integer holding the id for the user that is transfering the money",
"userTo" : "An integer holding the id for the user that is receiving the money",
"amount" : "A decimal indicating the amount to transfer",
"transferType" : "A string for the transfer type: Send or Request",
}
TransferStatusUpdateDto
{
"transferStatus" : "A string for the transer status: Pending, Approved, or Rejected"
}