This API transfers money between two accounts. The API uses frameworks only, like Spark, JOOQ.
Design and implement a RESTful API (including data model and the backing implementation) for money transfers between accounts.
- You can use Java or Kotlin.
- Keep it simple and to the point (e.g. no need to implement any authentication).
- Assume the API is invoked by multiple systems and services on behalf of end users.
- You can use frameworks/libraries if you like ( except Spring ), but don't forget about requirement #2 and keep it simple and avoid heavy frameworks.
- The datastore should run in-memory for the sake of this test.
- The final result should be executable as a standalone program (should not require a pre-installed container/server).
- Demonstrate with tests that the API works as expected.
- The code produced by you is expected to be of high quality.
- There are no detailed requirements, use common sense.
Run the command to start the server:
java -jar transfer-money-api.jar
- API requires 11 or newer version of JAVA installed on local machine.
API is built using Apache Maven. To build API run:
./build/mvn -DskipTests clean package
- POST /payments
- GET /payments
- GET /payments/{paymentId}
- POST /accounts
- GET /accounts
- GET /accounts/{accountId}
To execute a payment call POST /payments endpoint with the json payload:
{
"Data": {
"InstructedAmount": {
"Amount": "50.00",
"Currency": "EUR"
},
"DebtorAccount": {
"SchemeName": "BBAN",
"Identification": "DK120000400440116243",
"Name": "Joe T"
},
"CreditorAccount": {
"SchemeName": "BBAN",
"Identification": "GB371205100000309657",
"Name": "Jesica P"
}
}
}
Before the payment is executed, some validations must be applied. Both accounts (creditor and debtor) should be present and exist in DB. In order to create new accounts, use the endpoint:
POST /accounts
and provide the payload:
{
"Id": "LT470000600440112909",
"Name": "Mindaugas",
"Balance": "99.00",
"Currency": "EUR",
"Status": "ACTIVE"
}
For the sake of simplicity, the API only checks if all required fields are set properly, but it doesn't make any complicated validations.