amitwadhwa83 / TakeawayPay

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Takeaway Pay API

Swagger api : http://localhost:8080/swagger-ui/index.html

Notes:

I did not use any database implementations, but made a simple storage based on ConcurrentHashMap.

Build:

mvn clean package

Run:

  • Run the app, default port 8080:
java -jar target/TakeawayPay-0.0.1-SNAPSHOT.jar
  • Run the app, specify the port:
java -jar target/TakeawayPay-0.0.1-SNAPSHOT.jar -p 6666
  • Run Test Cases:
mvn test
HTTP METHOD PATH USAGE
GET /transfers/ get all transfers
GET /accounts/ get all acounts information
POST /transfer/create/ perform transfer between 2 accounts

How to use

With the Web server started and running, perform the following requests to consume the API:

List all transfers

Example request:

  • GET (/transfers)
Request:
GET /transfers

Example response:

[
  {
    "id": 1,
    "sourceAccount": 1,
    "destAccount": 2,
    "amount": 4,
    "lastUpdate": "2023-04-23T01:31:14.672742"
  }
]

List all accounts

Example request:

  • GET (/accounts/)
Request:
GET /accounts

Example response:

[
  {
    "id": 1,
    "balance": 36,
    "lastUpdate": "2023-04-23T01:31:12.006365",
    "customer": true
  },
  {
    "id": 2,
    "balance": 14,
    "lastUpdate": "2023-04-23T01:31:12.087122",
    "customer": false
  }
]

Take money from the customer's account and put it in the restaurant's account.

Example request:

  • POST (/transfer/create)

Example request:

Request:
POST /transfer/create
{
  "sourceAccount": 1,
  "destAccount": 2,
  "amount": 4,
  "lastUpdate": "2023-04-24T18:54:35.487Z"
}

Example response:

 3

About


Languages

Language:Java 100.0%