You are requested to create a service for the bank in this question.
Given the customer's name and amount of money to deposit or withdraw (by the number sign +/-), you should indicate the success or failure by the following:
If the customer balance doesn't have enough money for the withdrawal, you should return -1 to signal error, otherwise 0.
The current balances are as follows:
- BruceWayne -
- The current balance is 58$.
- ClarkKent -
- The current balance is 21$.
- DianaPrince -
- The current balance is 112$.
Your API should support the following:
Url: UpdateBalance
Method: POST
Request Body (as JSON) :
{
"customerName": ....,
"amount" : ....
}
The amount can be positive for a deposit or negative for a withdrawal.
Response: 0 for success, -1 for error.
Url: GetBalance
Method: GET
Parameters: customerName
Response: the customer balance.
*All responses must be strings (not numbers or objects)
For example:
/GetBalance?customerName=BruceWayne
Response: 58
--------
Post to /UpdateBalance:
{
"customerName": "BruceWayne",
"amount" : 5
}
Response: 0
--------
/GetBalance?customerName=BruceWayne
Response: 63
Because the balance was updated in the example above
--------
Post to /UpdateBalance:
{
"customerName": "BruceWayne",
"amount" : -500
}
Response: -1
Because the balance doesn't have enough money to withdraw 500$.