Giter VIP home page Giter VIP logo

bankingapi's Introduction

RUN WITH DOCKER

Run createDockerImage.bat for creating docker image\n Run runBankApiDocker.bat for running the created image

OR RUN WITHOUT DOCKER

\nRun runBankApi_NoDocker.bat

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

bankingapi's People

Contributors

nkdcoder avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.