3 relational tables to store customers information, accounts and transactions.
- added "identification" field for storing e.g. passport numbers to distinguish between customers with same names for example
Definition
GET /customers
Response
200 OK on success
[
{"customers": {
"id": 1,
"name": "Thomas Anderson",
"identification": "a232fdb9-c7c5-4ad0-b8df-e606bff483e6"
}}
]404 Not Found on error
Note: not adding list all accounts and list all transactions functionalities for security reasons. Only allow viewing of single account and transactions related to an account.
Definition
POST /customers
Arguments
"first_name": stringcustomer's first name (not case sensitive)"surname": stringcustomer's last name (not case sensitive)"identification": stringcustomer's identification document number
Response
201 created on success
[
{"SUCCESS": {
"message": "customer added",
"id": 1,
"name": "Thomas Anderson",
"identification": "a232fdb9-c7c5-4ad0-b8df-e606bff483e6"
}}
]400 Bad Request on error
- if customer already exists in database
- if missing argument
- if unknown error
Create a new bank account for a customer, with an initial deposit amount. A single customer may have multiple bank accounts.
Definition
POST /accounts
Arguments
"first_name": stringcustomer's first name (not case sensitive)"surname": stringcustomer's last name (not case sensitive)"identification": stringcustomer's identification document number"balance": floatinitial deposit
Response
201 created on success
[
{"SUCCESS": {
"message": "New account added",
"id": 1,
"balance": 100,
"customer_id": 1,
"name": "Thomas Anderson",
}}
]400 Bad Request on error
- if customer does not exist in database
- if missing argument
- if unknown error
Definition
POST /transactions
Arguments
"account_id_from": integeraccount id transferring from"account_id_to": integeraccount id transferring to"amount": floattransfer amount (cannot be negative)
Response
201 created on success
[
{
"uuid": "0734c20c-5807-4f20-8233-e1a861df8eea",
"account_id_from": 1,
"account_id_to": 2,
"amount": 10.50,
"transaction_timestamp": 2020-10-10 13:30:02
}
]400 Bad Request on error
- if account does not exist in database
- if amount is negative
- if missing argument
- if unknown error
Definition
GET /account/<account_id>
Response
200 OK on success
[
{"SUCCESS": {
"message": "account 1 retreived",
"balance": 100
}}
]404 Not Found on error
- if account does not exist in database
Definition
GET /account/<account_id>/transactions
Response
200 OK on success
[
{"transactions":{
"uuid": "0734c20c-5807-4f20-8233-e1a861df8eea",
"account_id_from": 1,
"account_id_to": 2,
"amount": 10.50,
"transaction_timestamp": "2020-10-10 13:30:02"
}}
]404 Not Found on error
- use MySQL or Postgres instead of sqlite, depends on exact application
- put limit on negative balance on accounts in transaction requests
- consider storing balance as integer to prevent rounding error (then divide by 100) e.g. store 10.50 as 1050
- more endpoints + routes (e.g. view all accounts, delete account etc.)
- login credentials to view all accounts, transactions