Skip to content

Latest commit

 

History

History
131 lines (105 loc) · 2.63 KB

README.md

File metadata and controls

131 lines (105 loc) · 2.63 KB

Thin Bank example

Ultra-simple bank account application. Supports create account, view account & transfer balance methods

Deploy it on Heroku

Deploy

Build Locally

To build & run the app use the following command:

git clone https://github.com/cikasfm/revolut-backend.git
cd revolut-backend
mvn clean compile exec:java

Open the address http://localhost:4567 in your browser to see the Swagger API definition test UI

Typical API commands

Create new account

One for the Bank

curl -X PUT "https://thin-bank.herokuapp.com/api/account?accountName=Bank" -H "accept: application/json"

Output:

{
  "status": 200,
  "message": "OK",
  "data": {
    "accountNumber": 1,
    "accountName": "Bank",
    "balance": 0
  }
}

One for a user named John

curl -X PUT "https://thin-bank.herokuapp.com/api/account?accountName=John" -H "accept: application/json"

Output:

{
  "status": 200,
  "message": "OK",
  "data": {
    "accountNumber": 2,
    "accountName": "John",
    "balance": 0
  }
}

Deposit cash to the account

curl -X POST "https://thin-bank.herokuapp.com/api/balance/deposit" \
  -H "accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{ \"toAcct\": 1, \"amount\": 999999999}"

Output:

{
  "status": 200,
  "message": "OK",
  "data": {
    "accountNumber": 1,
    "accountName": "Bank",
    "balance": 999999999.00
  }
}

Transfer balance

curl -X POST "https://thin-bank.herokuapp.com/api/balance/transfer" \
  -H "accept: application/json" \
  -H "Content-Type: application/json" \
  -d "{ \"fromAcct\": 1, \"toAcct\": 2, \"amount\": 100}"

Output

{
  "status": 200,
  "message": "OK"
}

View all account balances

curl -X GET "https://thin-bank.herokuapp.com/api/account/all?pageNum=0&pageSize=20" -H "accept: application/json"

Output

{
  "status": 200,
  "message": "OK",
  "data": [
    {
      "accountNumber": 1,
      "accountName": "Bank",
      "balance": 999999899
    },
    {
      "accountNumber": 2,
      "accountName": "John",
      "balance": 100
    }
  ]
}

Libraries used

  • Spark - A micro framework for creating web applications in Kotlin and Java 8 with minimal effort
  • H2 Database Engine
  • HikariCP - A solid, high-performance, JDBC connection pool at last.
  • SLF4J Simple Logging Facade for Java