Run createDockerImage.bat for creating docker image\n Run runBankApiDocker.bat for running the created image
Below are the API requirements implemented:
- A user can have as many accounts as they want.
- A user can be created with a name as input and an autogenerated 10 digit unique id is associated with him when he is created.
- A user name provided while creation can have only alphabets and space, no numbers or special characters other than space i.e. " " should be allowed.
- A new user gets one account automatically created for him with an amount deposit of $100.
- An account has a unique auto generated 16 digit numeric id associated at the time of creation.
- When a user is created successfully a response should return Id generated for the user along with information for the new autogenerated account with a success - message .
- A new account for user is always created with an amount deposit of $100.
- A user can delete one or multiple accounts.
- A user can only be deleted if no account is associated
- If a user with one or more accounts is tried to be deleted, message is shown saying "You have to delete all associated accounts first for the user"
- A amount provided for deposit and withdrawal can be numeric only.
- A user can deposit and withdraw from accounts.
- An account cannot have less than $100 at any time in an account and gets a message about it if he tries to withdraw that leads to this situation.
- A user cannot withdraw more than 90% of their total balance from an account in a single transaction and the same information is given in response.
- A user cannot deposit more than $10,000 in a single transaction and gets a message if he tries to do this.
Below are examples of actions you can perform with different endpoints:
==> Create a User Endpoint: POST /api/users Payload: { "name": "John Doe" } HTTP Method: POST
Response:
{
"userId": "ABC123",
"accountId": "XYZ789",
"message": "User created successfully with User 'John Doe', account XYZ789 and $100 deposit."
}
Status Code: 201 Created
==> Delete a User Endpoint: DELETE /api/users/{userId}
HTTP Method: DELETE
Response:
{
"message": "User with ID ABC123 deleted successfully."
}
Status Code: 200 OK
==> Create an Account for a User Endpoint: POST /api/users/{userId}/accounts
HTTP Method: POST
Response:
{
"accountId": "XYZ789",
"balance": 100,
"message": "Account created successfully with $100 deposit."
}
Status Code: 201 Created
==> Delete an Account for a User Endpoint: DELETE /api/users/{userId}/accounts/{accountId}
HTTP Method: DELETE
Response:
{
"message": "Account with ID XYZ789 deleted successfully for user ABC123."
}
Status Code: 200 OK
==> Deposit to an Account Endpoint: PUT /api/users/{userId}/accounts/{accountId}/deposit
Payload:
{
"amount": 50
}
HTTP Method: PUT
Response:
{
"message": "Deposit successfully."
}
Status Code: 204 No Content
==> Withdraw from an Account Endpoint: PUT /api/users/{userId}/accounts/{accountId}/withdraw
Payload:
{
"amount": 30
}
HTTP Method: PUT
Response:
{
"message": "Withdrawal successful."
}
Status Code: 204 No Content
==> Get a List of Users Endpoint: GET /api/users
HTTP Method: GET
Response:
[
{
"id": "ABC123"
},
{
"id": "DEF456"
}
]
Status Code: 200 OK
==> Get a User by ID Endpoint: GET /api/users/{userId}
HTTP Method: GET
Response:
{
"userId": "ABC123",
"userName": "John Doe",
"accounts": [
{
"accountId": "XYZ789",
"balance": 100
}
]
}
Status Code: 200 OK
==> Get a List of User Accounts Endpoint: GET /api/users/{userId}/accounts
HTTP Method: GET
Response:
[
{
"accountId": "XYZ789",
"balance": 100
}
]
Status Code: 200 OK
==> Get an Account by ID for a User Endpoint: GET /api/users/{userId}/accounts/{accountId}
HTTP Method: GET
Response:
{
"accountId": "XYZ789",
"balance": 100
}
Status Code: 200 OK
On my windows the API was exposed to https://localhost:5000 There is C# nunit restassured.net based BDD specflow test project for testing this api at https://github.com/nkDcoder/BankAPITests.git