Build and start docker container with:
docker-compose up --build
Wait initialization. When it's done you will see a message " * Running on http://127.0.0.1:5000"
Curl requests will return you a transaction ID.
- Put 1000.0 credits on to a client's account with id 1
curl "http://127.0.0.1:5000/1/1000.0/put"
- Withdraw 600.0 credits from the same client
curl "http://127.0.0.1:5000/1/600.0/withdraw"
- Try to withdraw another 600.0 credits from the same client
curl "http://127.0.0.1:5000/1/600.0/withdraw"
The last request will be cancelled because of low credits.
Use db's container CLI.
- Connect to the database
psql postgres://postgres:pg@localhost:5432/accounts
- Look at the history table
SELECT * FROM history;
There are two successfull transactions and one cancelled.
- Look at the accounts table
SELECT * FROM accounts;
There are 400 credits on the account of a client with ID=1.