Skip to content

Skiftcha/MoneyTransfer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoneyTransfer test application

To build and run unit tests

./gradlew build

To run application

./gradlew run

Runs application on 8080 port

To run intergation tests while application is running

./gradlew integrationTest

Runs integration tests accessing api via 8080 port

API Resources

GET /accounts

Returns list of accounts and their balance

Request body: no request body
Response body:
[
    {
        "id": 1,
        "balance": 5
    },
    {
        "id": 2,
        "balance": 333
    }
]
Example:
curl "http://localhost:8080/accounts"

GET /accounts/history

Returns money transfer history
null value in from or to field means it is deposit or withdrawal operation respectively

Request body: no request body
Response body:
[
    {
        "from": null,
        "to": 1,
        "amount": 10,
        "time": 1539565845785
    },
    {
        "from": 1,
        "to": null,
        "amount": 5,
        "time": 1539565845793
    },
    {
        "from": 6,
        "to": 7,
        "amount": 7,
        "time": 1539565845982
    }
]
Example:
curl "http://localhost:8080/accounts/history"

POST /accounts/create

Creates new account and returns its id

Request body: no request body
Response body:
13
Example:
curl -X POST "http://localhost:8080/accounts/create"

GET /accounts/[id]

Returns account balance
Returns 404 Not Found error if no account found

Request body: no request body
Response body:
444
Example:
curl "http://localhost:8080/accounts/3"

PUT /accounts/deposit

Increases account balance
Returns 404 Not Found error if no account found

Request body:
{
    "id": 2,
    "amount": 10
}
Response body: no response body
Example:
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/deposit" -d '{"id": 2, "amount": 10}'

PUT /accounts/withdraw

Decreases account balance
Returns 404 Not Found error if no account found
Returns 400 Bad Request error if not enough money for withdrawal

Request body:
{
    "id": 2,
    "amount": 10
}
Response body: no response body
Example:
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/withdraw" -d '{"id": 2, "amount": 10}'

PUT /accounts/transfer

Transfers balance between accounts
Returns 404 Not Found error if no account found
Returns 400 Bad Request error if not enough money for transfer

Request body:
{
    "from": 2,
    "to": 3,
    "amount": 10
}
Response body: no response body
Example:
curl -X PUT -H "Content-Type: application/json" "http://localhost:8080/accounts/transfer" -d '{"from": 2, "to": 3, "amount": 10}'

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages