项目作者: nejckorasa

项目描述 :
Sample app for money transfers between accounts
高级语言: Kotlin
项目地址: git://github.com/nejckorasa/transfer-money.git
创建时间: 2019-09-30T19:29:04Z
项目社区:https://github.com/nejckorasa/transfer-money

开源协议:

下载


transfer-money

Build Status

Sample app for money transfers between accounts. It supports account creation with initial balance and issuing money transfers between accounts.

It is build using Javalin with Guice and Kotlin. Hibernate with H2 in-memory database.

Tested with JUnit5 and REST-assured

It includes examples for both DB locking and Thread locking.

Running

Server starts on: http://localhost:7000

To start the server:

  1. ./mvnw compile exec:java

Or build jar and run it:

  1. ./mvnw package && java -jar target/transfer-money-1.0-SNAPSHOT-jar-with-dependencies.jar

REST API


Click to expand!

### Accounts

- GET /api/accounts
Get all accounts
Successful response: 200
Example response:
json [ { "accountId": 1, "balance": 200.00 }, { "accountId": 2, "balance": 100.00 } ]

- GET /api/accounts/:id
get account by id
Successful response: 200
Example response:
json { "accountId": 1, "balance": 200.00 }
- POST /api/accounts
Create account
Request body:
json { "balance": 200.00 }
Successful response: 201
Example response:
json { "accountId": 1, "balance": 200.00 }

### Transfers

- GET /api/transfers
Get all transfers
Successful response: 200
Example response:
json [ { "transferId": 1, "sourceAccountId": 1, "destinationAccountId": 2, "amount": 50.00, "createdAt": "2019-09-30T20:57:02.15", "status": "SUCCESS" }, { "transferId": 2, "sourceAccountId": 1, "destinationAccountId": 2, "amount": 50.00, "createdAt": "2019-09-30T20:57:03.102", "status": "FAILED" }, { "transferId": 3, "sourceAccountId": 1, "destinationAccountId": 2, "amount": 50.00, "createdAt": "2019-09-30T20:57:05.397", "status": "REQUESTED" } ]

- POST /api/transfers
Create transfer
Request body:
json { "sourceAccountId": 1, "destinationAccountId": 2, "amount": 50.0 }
Successful response: 201
Example response:
json { "transferId": 1, "sourceAccountId": 1, "destinationAccountId": 2, "amount": 50.00, "createdAt": "2019-09-30T20:57:02.15", "status": "SUCCESS" }