MoneyTransfer is an app that provides a simple RESTful API to transfer money between accounts.
~$ java -jar transmitter.jarBy default the app runs on port number 4567.
localhost:4567 Description:
You can call completed transfers.
API responds with a JSON object with a list of
descriptions of transfers.
API call:
GET localhost:4567/api/transfersExample response
{
"status": "SUCCESS",
"data": [
{
"id": 1,
"senderAccount": {
"id": 1,
"priority": 0
},
"receiverAccount": {
"id": 3,
"priority": 0
},
"sum": 200,
"timestamp": "Jun 4, 2018 12:28:51 PM"
}
]
}id identifier of a transfer (a number of long type)
Description:
You can call a completed transfer by its id.
API responds with a JSON object with
the description of the transfer that match the id.
API call:
GET localhost:4567/api/transfers/:idParameters
id identifier of a transfer (a number of long type)
Example request
localhost:4567/api/transfers/1Example response
{
"status": "SUCCESS",
"data": {
"id": 1,
"senderAccount": {
"id": 1,
"priority": 0
},
"receiverAccount": {
"id": 3,
"priority": 0
},
"sum": 200,
"timestamp": "Jun 4, 2018 12:28:51 PM"
}
}Description:
You can make a money transfer specifying
a sender account id, a receiver account id and a sum of money (in currency of the sender's account).
Pay attention that you have to specify parameters of the request
in its body in JSON format.
API responds with a JSON object with
the description of the completed transfer.
API call:
POST localhost:4567/api/transfers/makeParameters
senderAccountId identifier of the account of the sender
receiverAccountId identifier of the account of the receiver
sum sum of money to transfer
Example request
localhost:4567/api/transfers/make
{
"senderAccountId": "1",
"receiverAccountId": "3",
"sum": "200"
}Example response
{
"status": "SUCCESS",
"data": {
"id": 2,
"senderAccount": {
"id": 1,
"customer": {
"id": 1
},
"balance": 600,
"priority": 1,
"currency": "RUB"
},
"receiverAccount": {
"id": 3,
"customer": {
"id": 2
},
"balance": 2400,
"priority": 1,
"currency": "RUB"
},
"sum": 200,
"timestamp": "Jun 4, 2018 12:40:44 PM"
}
}Description:
You can make a money transfer specifying
both sender's and receiver's phone numbers and a sum of money (in currency of the sender's account).
Pay attention that you have to specify parameters of the request
in its body in JSON format.
API responds with a JSON object with
the description of the completed transfer.
API call:
localhost:4567/api/transfers/makebyphoneParameters
senderPhoneNumber the phone number of the sender
receiverPhoneNumber the phone number of the receiver
sum sum of money to transfer
Example request
localhost:4567/api/transfers/makebyphone
{
"senderPhoneNumber": "+7911111111",
"receiverPhoneNumber": "+79055555555",
"sum": "200"
}Example response
{
"status": "SUCCESS",
"data": {
"id": 3,
"senderAccount": {
"id": 1,
"customer": {
"id": 1
},
"balance": 400,
"priority": 1,
"currency": "RUB"
},
"receiverAccount": {
"id": 4,
"customer": {
"id": 3
},
"balance": 3200,
"priority": 1,
"currency": "RUB"
},
"sum": 200,
"timestamp": "Jun 4, 2018 12:45:40 PM"
}
}When your call fails by some reason you get a JSON object with
the description of the error.
Example of bad request (wrong phone number of the sender)
localhost:4567/api/transfers/makebyphone
{
"senderPhoneNumber": "+7911111111",
"receiverPhoneNumber": "+79055555555",
"sum": "200"
}Example response
{
"status": "ERROR",
"message": "Customer not found"
}