- Requires
Python 3.8
or above installed - Install dependencies
pip install -r requirements.txt
- Create database
python manage.py migrate
- Create test user
python manage.py createsuperuser
- Run server
python manage.py runserver
Note: tests can be run using python manage.py test
/<user_id>/wallet/
root node to access all functionalities for the wallet associated with user of id user_idcreate/
(POST) creates new walletbalance/
(GET) gets current balancedebit/
(POST) debits amountcredit/
(POST) credits amount
Responses are returned in JSON format. Each response has a success field which indicates whether the given action was successfully performed or not. In case of failure, there is an error field which indicates the type of error which occurred.
curl --request POST --url http://localhost:8000/1/wallet/create/
create a new wallet for user 1curl --request GET --url http://localhost:8000/1/wallet/balance/
get balance for wallet of user 1. returns {"success": true, "balance": 100}curl --request POST --url http://localhost:8000/1/wallet/debit/ -H "Content-Type: application/json" -d '{"amount": 20}'
debit 20 amount from wallet of user 1curl --request POST --url http://localhost:8000/1/wallet/credit/ -H "Content-Type: application/json" -d '{"amount": 20}'
credit 20 amount to wallet of user 1
- all transactions create a log entry in the log file for the respective wallet. log files can be found in logs/ directory with format wallet<wallet_id>.log
- debit transactions fail if balance is less than minimum balance (currently set to 100. can be adjusted in server/config.py)
- this API does not handle user creation and authentication
- only 1 create or credit or debit transaction is performed at a time for a user