Banking API, where it is possible to make withdrawals and transfers between users
Make sure you have elixir and docker in your machine. If you don't have them, you can install here:
elixir: https://elixir-lang.org/install.html
docker: https://docs.docker.com/get-docker/
In the project's root folder, run this command to have a Postgres database running on port 5432:
# Running a database on port 5432
docker-compose up -d
Configure the database and download the dependencies (in the root folder):
mix setup
Run tests:
mix test
Start the server:
iex -S mix phx.server
Route: /api/accounts
Method: POST
{
"user": "Some name"
}
If the input is valid (it's a string type, and the user it is not already taken), you will receive an awnser like this:
{
"account": {
"balance": 1000,
"user": "Some name"
},
"message": "Account created"
}
Route: /api/accounts/withdraw
Method: POST
{
"user": "Some name",
"value": 10
}
If the user exists and the value is valid (value <= balance), you will receive an awnser like this:
{
"account": {
"balance": 990,
"user": "Some name"
},
"message": "Balance changed succesfully"
}
Route: /api/accounts/transaction
Method: POST
{
"from": "Some name",
"to": "Another name",
"value": 10
}
If both users exist and the value is valid (value <= balance), you will receive an awnser like this:
{
"deposit": {
"balance": 1100,
"user": "Another name"
},
"message": "Transaction done succesfully",
"withdraw": {
"balance": 980,
"user": "Some name"
}
}
Route: /api/accounts/:id
Method: GET
If the given id belongs to an account, you will receive an awnser like this:
{
"description":
"Your current balance is 940"
}