Skip to content

bvighnesha/revolut

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The REST Api for money transfer. Technologies used:

  1. Maven as project management tool
  2. SparkJava framework for REST
  3. Guice for dependency injection
  4. JUnit and Mockito for testing

API Documentation is available in

\revolut\target\site\apidocs or https://vighnesh.org/revolut/apidocs

Usage

To run the application:

  1. mvn clean package //will create jar file
  2. java -jar revolut\target\revolut-1.0-SNAPSHOT.jar //will run application on port 8080

Implementations

This application has two impementations of services:

  1. When datastore is represented as Map.
  2. When datastore is represented as H2 (in-memory) database.

By default application starts in MAP mode (using Map as datastore). User can specify the mode when the programm is started:

  1. SQL mode: java -jar revolut\target\revolut-1.0-SNAPSHOT.jar SQL

Api's

Description Request Path Response Example
Create new account with balance POST /account JSON with info about account Input:
{ "balance": 100 }
Output:
{ "id": 1, "balance": 100}
Get account by id GET /account/{id} JSON with info about account Output:
{ "id": 1, "balance": 100}
Transfer money POST /transfer JSON with info about transfer status Input:
{ "fromId": 1, "toId": 2, "amount": 100 }
Output:
{Transfer Completed}

Example CURLs

curl -i -d "{ \"balance\": 100 }" --header "Content-Type: application/json" -X POST http://localhost:8080/account

curl -i -d "{\"fromId\": 1, \"toId\": 2, \"amount\": 100}" --header "Content-Type: application/json" -X POST http://localhost:8080/transfer

curl -i --header "Content-Type: application/json" -X GET http://localhost:8080/account/2

The possible exceptions:

  1. In case the account doesn't exists (int get account or transfer REST calls) the "Account with id = {id} wasn't found" will be displayed;
  2. In case transfer is happening to the same account the "Can't transfer the money to the same account." will be displayed;
  3. In case the balance on the fromAccount is less than the required amout the "Account with id = {id} doesn't have enough balance to transfer this amount = {amount}" will be displayed;

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published