-
Notifications
You must be signed in to change notification settings - Fork 7
post transactions
Harmun edited this page May 16, 2019
·
1 revision
post | /transactions | Admin/User | Add transaction | { debitAccountId, creditAccountId, amount } | { id, debitAccountId, creditAccountId, amount, date } |
Creates a new transaction between a debit account and a credit account identified by their ids.
Transactions are assigned their own IDs on creation.
- Both accounts need to exist before a transaction is made.
- Only an existing user can be the owner of a newly created account
- The user must own debit account, unless they have the admin role
- The account must contain enough to fullfil the transaction
- The
amount
field must be a positive integer
Request formats | JSON |
Requires authentication? | Yes |
amount | positive integer only |
Name | Required | Description | Role | Example |
---|---|---|---|---|
debitAccountId | required | Account to be debited | user | 10 |
creditAccountId | required | Account to be credited | user | 12 |
amount | required | Transaction amount | user | 1400 |
curl -X POST \
http://localhost:3000/transactions \
-H 'Authorization: Bearer 123testtoken123' \
-H 'Content-Type: application/json' \
-H 'Host: localhost:3000' \
-d '{
"debitAccountId" : 2,
"creditAccountId" : 3,
"amount" : 100
}'
After you post successfully you should get back the transaction's information like this:
{
"id": 110,
"debitAccountId": 2,
"creditAccountId": 3,
"amount": 100,
"date": "2019-05-16T15:15:49.000Z"
}
TODO: to make a deposit -> debit equity
TODO: to make a withdrawal -> credit equity