A standalone and lightweight Rest API powered by Jetty Server
The goal is to provide a apis allowing to provide money transfer / withdraw / deposit
.
├── account (rest api)
├── user (rest api)
└── data.sql (data of application)
Out of the box, we've got :
- JDK 11
- Jetty server / Jersey
- Database : H2
- Testing :
- Dao test with H2/junit
- Api test with jersey test framework/junit
Need Java 11 to launch
mvn clean install
java -jar the-bank-1.0.0-SNAPSHOT.jar YourPath/data.sql
Create a user
curl -X POST \
http://localhost:8080/api/users \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"username": "dgreenwich",
"firstName": "Daniel",
"lastName": "Greenwich",
"email": "d.greenwich@mail.com"
}'
Verify the user created
curl -X GET \
http://localhost:8080/api/users/dgreenwich \
-H 'cache-control: no-cache'
Waiting result
{
"id": 4,
"username": "dgreenwich",
"firstName": "Daniel",
"lastName": "Greenwich",
"email": "d.greenwich@mail.com"
}
Create an account for the created user
curl -X POST \
http://localhost:8080/api/accounts \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"username":"dgreenwich",
"name":"Bank Account",
"balance":"100",
"currency":"EUR"
}'
Verify the account created
curl -X GET \
http://localhost:8080/api/accounts/6 \
-H 'cache-control: no-cache'
Waiting result
{
"id": 6,
"username": "dgreenwich",
"name": "Bank Account",
"balance": 100,
"currency": "EUR"
}
Make a deposit on his created account
curl -X PUT \
http://localhost:8080/api/accounts/6/deposit/100 \
-H 'cache-control: no-cache'
Verify the deposit on account
curl -X GET \
http://localhost:8080/api/accounts/6 \
-H 'cache-control: no-cache'
Waiting result
{
"id": 6,
"username": "dgreenwich",
"name": "Bank Account",
"balance": 200,
"currency": "EUR"
}
And make a money transfer to an existing account
curl -X POST \
http://localhost:8080/api/accounts/transfer \
-H 'Content-Type: application/json' \
-H 'cache-control: no-cache' \
-d '{
"to": "6",
"from": "3",
"amount": "100",
"currency": "EUR"
}'
Verify the debited account
curl -X GET \
http://localhost:8080/api/accounts/3 \
-H 'cache-control: no-cache'
Waiting result
{
"id": 3,
"username": "jdeer",
"name": "Bank Account",
"balance": 200,
"currency": "EUR"
}
Verify the credited account
curl -X GET \
http://localhost:8080/api/accounts/6 \
-H 'cache-control: no-cache'
Waiting result
{
"id": 6,
"username": "dgreenwich",
"name": "Bank Account",
"balance": 100,
"currency": "EUR"
}