Skip to content

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 }

POST transactions

Creates a new transaction between a debit account and a credit account identified by their ids.
Transactions are assigned their own IDs on creation.

Restrictions

  • 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

Resource Information

Request formats JSON
Requires authentication? Yes
amount positive integer only

Fields

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

Example Request

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
}'

Example Response

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"
}

Deposits

TODO: to make a deposit -> debit equity

Withdrawals

TODO: to make a withdrawal -> credit equity