Simple money transfer web service.
- simple account management
- money transfers between accounts
- REST API
- authentication unsupported
- in-memory storage – accounts are forgotten on server restart
- Java 8
- Jersey Web Services / JAX-RS
- Jackson JSON
- Maven
- build:
mvn clean package
- run:
mvn exec:java
- apply code changes and run:
mvn compile exec:java
Description of API endpoints with examples of request / response.
Dynamic information about available endpoints is available on running server at http://localhost:8080/application.wadl
.
POST /accounts
curl -X "POST" "http://localhost:8080/accounts" \
-H 'Content-Type: application/json' \
-d $'{
"balance": "700"
}'
HTTP/1.1 201 Created
Location: http://localhost:8080/accounts/1
Content-Type: application/json
{
"id" : 1,
"balance" : 700
}
GET /accounts/{accountId}
curl "http://localhost:8080/accounts/3"
HTTP/1.1 200 OK
Content-Type: application/json
Connection: close
Content-Length: 33
{
"id" : 3,
"balance" : 700
}
GET /accounts
curl "http://localhost:8080/accounts"
HTTP/1.1 200 OK
Content-Type: application/json
[ {
"id" : 1,
"balance" : 700
}, {
"id" : 2,
"balance" : 700
} ]
DELETE /accounts/{accountId}
curl -X "DELETE" "http://localhost:8080/accounts/4"
HTTP/1.1 204 No Content
POST /accounts/transfer
curl -X "POST" "http://localhost:8080/accounts/transfer" \
-H 'Content-Type: application/json' \
-d $'{
"withdrawalAccountId": 1,
"depositAccountId": 2,
"amount": 150
}'
HTTP/1.1 200 OK
Content-Type: application/json
{
"withdrawalAccount" : {
"id" : 1,
"balance" : 550
},
"depositAccount" : {
"id" : 2,
"balance" : 850
},
"amount" : 150
}
- 400 Bad Request: Invalid transfer parameters
- 404 Not Found: Account not found
- 406 Not Acceptable: Insufficient funds