This api was developed as a technical test for a job interview
Hope you enjoy it
To see the API working, follow the steps below:
Initialize the app and database
$ make devCreate a new account with a unique account number.
Request
POST /accounts| Parameter | Type | Requirement | Description |
|---|---|---|---|
account_number |
string |
Required | Unique account number |
| Http code | Description | Schema |
|---|---|---|
201 |
Account created successfully | No Content |
400 |
Bad Request | RequestInvalidException |
409 |
Account already exists | AccountAlreadyExistsException |
curl --request POST \
--url 'http://localhost:3000/accounts' \
--header 'Content-Type: application/json' \
--data '{ "account_number": "123" }'Make a peer-to-peer transfer between two existing accounts.
Request
POST /accounts/transfer| Parameter | Type | Requirement | Description |
|---|---|---|---|
amount |
number |
Required | The amount in cents |
from |
string |
Required | Origin account |
to |
string |
Required | Destination account |
| Http code | Description | Schema |
|---|---|---|
200 |
Transfer made successfully | No Content |
400 |
Bad Request | RequestInvalidException |
409 |
Insufficient balance | TransferInsufficientFunds |
404 |
Destination account not found | TransferInvalidDestinationException |
404 |
Origin account not found | AccountNotFoundException |
curl --request POST \
--url http://localhost:3000/accounts/transfer \
--header 'Content-Type: application/json' \
--data '{ "from": "123", "to": "456", "amount": 100 }'Get the current balance of an account.
Request
GET /accounts/:accountNumber/balance| Parameter | Type | Requirement | Description |
|---|---|---|---|
accountNumber |
string | Required | The account id |
| Http code | Description | Schema |
|---|---|---|
200 |
Successful operation | No Content |
400 |
Bad Request | RequestInvalidException |
404 |
Account not found | AccountNotFoundException |
curl --request GET \
--url http://localhost:3000/accounts/123/balanceDeposit funds into an existing account.
Request
POST /accounts/:accountNumber/deposit| Parameter | Type | Requirement | Description |
|---|---|---|---|
accountNumber |
string | Required | The account id |
| Parameter | Type | Requirement | Description |
|---|---|---|---|
amount |
number |
Required | The amount in cents |
| Http code | Description | Schema |
|---|---|---|
200 |
Deposit made successfully | No Content |
400 |
Bad Request | RequestInvalidException |
404 |
Account not found | AccountNotFoundException |
curl --request POST \
--url http://localhost:3000/accounts/123/deposit \
--header 'Content-Type: application/json' \
--data '{ "amount": 1000 }'# Run unit tests
$ make test-unit
# Run integration tests
$ make test-integration
# Run e2e tests
$ make test-e2e