./gradlew build
./gradlew run
Runs application on 8080 port
./gradlew integrationTest
Runs integration tests accessing api via 8080 port
- GET /accounts
- GET /accounts/history
- POST /accounts/create
- GET /accounts/[id]
- PUT /accounts/deposit
- PUT /accounts/withdraw
- PUT /accounts/transfer
Returns list of accounts and their balance
[
{
"id": 1,
"balance": 5
},
{
"id": 2,
"balance": 333
}
]
curl "http://localhost:8080/accounts"
Returns money transfer history
null value in from or to field means it is deposit or withdrawal operation respectively
[
{
"from": null,
"to": 1,
"amount": 10,
"time": 1539565845785
},
{
"from": 1,
"to": null,
"amount": 5,
"time": 1539565845793
},
{
"from": 6,
"to": 7,
"amount": 7,
"time": 1539565845982
}
]
curl "http://localhost:8080/accounts/history"
Creates new account and returns its id
13
curl -X POST "http://localhost:8080/accounts/create"
Returns account balance
Returns 404 Not Found error if no account found
444
curl "http://localhost:8080/accounts/3"
Increases account balance
Returns 404 Not Found error if no account found
{
"id": 2,
"amount": 10
}
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/deposit" -d '{"id": 2, "amount": 10}'
Decreases account balance
Returns 404 Not Found error if no account found
Returns 400 Bad Request error if not enough money for withdrawal
{
"id": 2,
"amount": 10
}
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/withdraw" -d '{"id": 2, "amount": 10}'
Transfers balance between accounts
Returns 404 Not Found error if no account found
Returns 400 Bad Request error if not enough money for transfer
{
"from": 2,
"to": 3,
"amount": 10
}
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/transfer" -d '{"from": 2, "to": 3, "amount": 10}'