Skip to content

MacAdaMm/TEnmo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Module 2 Capstone - TEnmo

Congratulations—you've landed a job with TEnmo, 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.

Use cases

Required use cases

You should attempt to complete all of the following required use cases.

  1. [COMPLETED] As a user of the system, I need to be able to register myself with a username and password.
    1. A new registered user starts with an initial balance of 1,000 TE Bucks.
    2. The ability to register has been provided in your starter code.
  2. [COMPLETED] As a user of the system, I need to be able to log in using my registered username and password.
    1. 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.
    2. The ability to log in has been provided in your starter code.
  3. As an authenticated user of the system, I need to be able to see my Account Balance.
  4. 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.
    1. I should be able to choose from a list of users to send TE Bucks to.
    2. A transfer should include the User IDs of the from and to users and the amount of TE Bucks.
    3. A Sending Transfer has an initial status of Approved.
    4. The receiver's account balance is increased by the amount of the transfer.
    5. The sender's account balance is decreased by the amount of the transfer.
    6. I must not be allowed to send money to myself.
    7. I can't send more TE Bucks than I have in my account.
    8. I can't send a zero or negative amount.
  5. As an authenticated user of the system, I need to be able to see transfers I have sent or received.
  6. As an authenticated user of the system, I need to be able to retrieve the details of any transfer based upon the transfer ID.

Optional use cases

If you complete all of the required use cases and are looking for additional challenge, complete as many of the following optional use cases as you can.

  1. 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.

    1. I should be able to choose from a list of users to request TE Bucks from.
    2. A transfer includes the User IDs of the from and to users and the amount of TE Bucks.
    3. A Request Transfer has an initial status of Pending.
    4. No account balance changes until the request is approved.
    5. The transfer request should appear in both users' list of transfers (required use case #5).
    6. I can't request a zero or negative amount.
    7. I must not be allowed to request money from myself.
  2. As an authenticated user of the system, I need to be able to see my Pending transfers.

  3. As an authenticated user of the system, I need to be able to either approve or reject a Request Transfer.

    1. The Request Transfer status is Approved if I approve, or Rejected if I reject the request.
    2. If the transfer is approved, the requester's account balance is increased by the amount of the request.
    3. If the transfer is approved, the requestee's account balance is decreased by the amount of the request.
    4. If the transfer is rejected, no account balance changes.
    5. I can't "approve" a given Request Transfer for more TE Bucks than I have in my account.

Sample screens

Use case 3: Current balance

Your current account balance is: $9999.99

Use case 4: Send TE Bucks

Please choose an option: 4
|-------------- Users --------------|
|    Id | Username                  |
|-------+---------------------------|
|  1002 | Bernice                   |
|  1003 | Deandre                   |
|-----------------------------------|
Id of the user you are sending to[0]: 1003
Enter amount to send: 75.74

Use case 5: View transfers

-------------------------------------------
Transfers
ID          From/To                 Amount
-------------------------------------------
23          From: Bernice          $ 903.14
79          To:    Larry           $  12.55
---------
Please enter transfer ID to view details (0 to cancel): "

Use case 6: Transfer details

--------------------------------------------
Transfer Details
--------------------------------------------
 Id: 23
 From: Bernice
 To: Me Myselfandi
 Type: Send
 Status: Approved
 Amount: $903.14

Use case 7: Requesting TE Bucks

Please choose an option: 5
|-------------- Users --------------|
|    Id | Username                  |
|-------+---------------------------|
|  1002 | Bernice                   |
|  1003 | Deandre                   |
|-----------------------------------|
Id of the user you are requesting from[0]: 1002
Enter amount to request: 39.99

Use case 8: Pending requests

-------------------------------------------
Pending Transfers
ID          To                     Amount
-------------------------------------------
88          Bernice                $ 142.56
147         Larry                  $  10.17
---------
Please enter transfer ID to approve/reject (0 to cancel): "

Use case 9: Approve or reject pending transfer

1: Approve
2: Reject
0: Don't approve or reject
---------
Please choose an option:

Database schema

Database schema

tenmo_user table


Stores the login information for users of the system.

Field Description
user_id Unique identifier of the user
username String that identifies the name of the user; used as part of the login process
password_hash Hashed version of the user's password
salt String that helps hash the password

account table


Stores the accounts of users in the system.

Field Description
account_id Unique identifier of the account
user_id Foreign key to the users table; identifies user who owns account
balance The amount of TE bucks currently in the account

transfer_type table


Stores the types of transfers that are possible.

Field Description
transfer_type_id Unique identifier of the transfer type
transfer_type_desc String description of the transfer type

There are two types of transfers:

transfer_type_id transfer_type_desc Purpose
1 Request Identifies transfer where a user requests money from another user
2 Send Identifies transfer where a user sends money to another user

transfer_status table


Stores the statuses of transfers that are possible.

Field Description
transfer_status_id Unique identifier of the transfer status
transfer_status_desc String description of the transfer status

There are three statuses of transfers:

transfer_status_id transfer_status_desc Purpose
1 Pending Identifies transfer that hasn't occurred yet and requires approval from the other user
2 Approved Identifies transfer that has been approved and occurred
3 Rejected Identifies transfer that wasn't approved

transfer table


Stores the transfers of TE bucks.

Field Description
transfer_id Unique identifier of the transfer
transfer_type_id Foreign key to the transfer_types table; identifies type of transfer
transfer_status_id Foreign key to the transfer_statuses table; identifies status of transfer
account_from Foreign key to the accounts table; identifies the account that the funds are being taken from
account_to Foreign key to the accounts table; identifies the account that the funds are going to
amount Amount of the transfer

Note: there are two check constraints in the DDL that creates the transfer table. Be sure to take a look at tenmo.sql to understand these constraints.

How to set up the database

In the database folder, you'll find the database creation script tenmo.sql. Open this in SQL Server Management Studio and execute it.

Authentication

The user registration and authentication functionality for the system has already been implemented. If you review the login code in TenmoApp.cs, you'll notice that after a successful authentication, the user is stored in AuthenticatedApiService, which is a base class for any API service that needs authentication. TenmoApiService derives from AuthenticatedApiService. At the same time the user is stored, the token is also stored in the IRestClient in that class.

AuthenticatedApiService also has three handy properties you may need in your client program:

  • IsLoggedIn is a boolean telling whether the user has been authenticated.
  • UserId is an integer which holds the user's id (when IsLoggedIn == true).
  • Username is a string which holds the user's name (when IsLoggedIn == true).

Set startup projects

Since both the client and server applications are included in the solution, you'll have to configure the solution to run both projects simultaneously. In Visual Studio, right-click the solution and select Set Startup Projects.... In the window that appears, select Multiple startup projects and set both "TenmoClient" and "TenmoServer" to have the action Start.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published