You can also add
--header 'Idempotency-Key: <Your key>'on every request. But it is optional. If not added Idempotency won't be provided! Also for key it is better to use UUID.
Request
curl --request POST \
--url http://localhost:8000/create_account \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"username": "<username>",
"name": "<full name>"
}'Response
{
"message": "Account created successfully"
}Request
curl --request GET \
--url 'http://localhost:8000/get_account?username=raju' \
--header 'Authorization: Bearer <API KEY>' Response
{
"username": "<username>",
"name": "<Full Name>",
"balance": <balance>
}Request
curl --request POST \
--url http://localhost:8000/add_webhook \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"listening_account": "<username>",
"url": "http://localhost:3000/"
}'Response
{
"message": "Added webhook"
}Request
curl --request POST \
--url http://localhost:8000/credit_account \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"receiver": "<username>",
"amount": <balance>
}'Response
{
"id": <transaction id>
}Request
curl --request POST \
--url http://localhost:8000/debit_account \
--header 'Authorization: Bearer <API KEY>' \
--header 'Content-Type: application/json' \
--data '{
"receiver": "<username>",
"amount": <balance>
}'Response
{
"id": <transaction id>
}Request
curl --request POST \
--url http://localhost:8000/transfer_funds \
--header 'Authorization: Bearer 7f853b13-fc18-4cbb-a80e-3c6002ef7bb4' \
--header 'Content-Type: application/json' \
--data '{
"sender": "<username>",
"receiver": "<username>",
"amount": <amount>
}'Response
{
"id": <transaction id>
}All Errors comes in following format
{
"error": "<message>"
}I didn't do too much testing to add status code for all errors. I did have defined many in src/errors.rs
The software is not tested enough to be very reliable. Some of the errors might not be well verbose.