SudoSOS Back-end API / transactions / TransactionController
Class: TransactionController ​
The BaseController class is responsible for:
- Storing route definitions.
- Generating router objects based on the policy.
Extends ​
Constructors ​
Constructor ​
new TransactionController(options): TransactionController;Creates a new transaction controller instance.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
options | BaseControllerOptions | The options passed to the base controller. |
Returns ​
TransactionController
Overrides ​
Properties ​
| Property | Modifier | Type | Description | Inherited from |
|---|---|---|---|---|
roleManager | protected | RoleManager | A reference to the role manager passed in the base controller options. | BaseController.roleManager |
specification | public | SwaggerSpecification | A reference to the swagger specification passed in the base controller options. | BaseController.specification |
Methods ​
createTransaction() ​
createTransaction(req, res): Promise<void>;POST /transactions
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The created transaction entity
Operation Id ​
createTransaction
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
deleteTransaction() ​
deleteTransaction(req, res): Promise<void>;DELETE /transactions/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
204 - No content
Operation Id ​
deleteTransaction
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
getAllTransactions() ​
getAllTransactions(req, res): Promise<void>;GET /transactions
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - A list of all transactions
Operation Id ​
getAllTransactions
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
getPolicy() ​
getPolicy(): Policy;Gets the policy defined by child classes. This policy includes all routes that the controller accepts, the authorization middleware, and the final handler function for every route.
Returns ​
The policy of this controller.
Overrides ​
getRouter() ​
getRouter(): Router;Returns ​
Router
the router used by this controller.
Inherited from ​
getTransaction() ​
getTransaction(req, res): Promise<void>;GET /transactions/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - Single transaction with given id
Operation Id ​
getSingleTransaction
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
getTransactionInvoices() ​
getTransactionInvoices(req, res): Promise<void>;GET /transactions/{id}/invoices
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - List of invoices
Operation Id ​
getTransactionInvoices
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
getTransactionPdf() ​
getTransactionPdf(req, res): Promise<void>;GET /transactions/{id}/pdf
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The requested pdf of the transaction - application/pdf
Operation Id ​
getTransactionPdf
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
updateTransaction() ​
updateTransaction(req, res): Promise<void>;PATCH /transactions/
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - The requested transaction entity
Operation Id ​
updateTransaction
Tags ​
transactions - Operations of transaction controller
Security ​
JWT
validateTransaction() ​
validateTransaction(req, res): Promise<void>;POST /transactions/validate
Parameters ​
| Parameter | Type |
|---|---|
req | RequestWithToken |
res | Response |
Returns ​
Promise<void>
200 - Transaction validated
Operation Id ​
validateTransaction
Tags ​
transactions - Operations of the transaction controller
Security ​
JWT
filterRelation() ​
static filterRelation(req): Promise<"all" | "organ" | "own">;Determines the relation between the user and the transaction (by filters in the request).
- Returns 'own' if user is from, to, or createdBy.
- Returns 'organ' if user shares an organ with any of those users.
- Returns 'all' otherwise.
Parameters ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | Express request with user token and filters in query params. |
Returns ​
Promise<"all" | "organ" | "own">
'own' | 'organ' | 'all'
getRelation() ​
static getRelation(req): Promise<string>;Function to determine which credentials are needed to get transactions all if user is not connected to transaction organ if user is not connected to transaction via organ own if user is connected to transaction
Parameters ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | Request with transaction id as param |
Returns ​
Promise<string>
whether transaction is connected to user token
postRelation() ​
static postRelation(req): Promise<string>;Function to determine which credentials are needed to post transaction all if user is not connected to transaction other if transaction createdby is and linked via organ own if user is connected to transaction
Parameters ​
| Parameter | Type | Description |
|---|---|---|
req | RequestWithToken | Request with TransactionRequest in the body |
Returns ​
Promise<string>
whether transaction is connected to user token