Skip to content

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 ​

ts
new TransactionController(options): TransactionController;

Creates a new transaction controller instance.

Parameters ​

ParameterTypeDescription
optionsBaseControllerOptionsThe options passed to the base controller.

Returns ​

TransactionController

Overrides ​

BaseController.constructor

Properties ​

PropertyModifierTypeDescriptionInherited from
roleManagerprotectedRoleManagerA reference to the role manager passed in the base controller options.BaseController.roleManager
specificationpublicSwaggerSpecificationA reference to the swagger specification passed in the base controller options.BaseController.specification

Methods ​

createTransaction() ​

ts
createTransaction(req, res): Promise<void>;

POST /transactions

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The created transaction entity

Operation Id ​

createTransaction

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


deleteTransaction() ​

ts
deleteTransaction(req, res): Promise<void>;

DELETE /transactions/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

204 - No content

Operation Id ​

deleteTransaction

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


getAllTransactions() ​

ts
getAllTransactions(req, res): Promise<void>;

GET /transactions

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - A list of all transactions

Operation Id ​

getAllTransactions

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


getPolicy() ​

ts
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 ​

Policy

The policy of this controller.

Overrides ​

BaseController.getPolicy


getRouter() ​

ts
getRouter(): Router;

Returns ​

Router

the router used by this controller.

Inherited from ​

BaseController.getRouter


getTransaction() ​

ts
getTransaction(req, res): Promise<void>;

GET /transactions/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - Single transaction with given id

Operation Id ​

getSingleTransaction

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


getTransactionInvoices() ​

ts
getTransactionInvoices(req, res): Promise<void>;

GET /transactions/{id}/invoices

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - List of invoices

Operation Id ​

getTransactionInvoices

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


getTransactionPdf() ​

ts
getTransactionPdf(req, res): Promise<void>;

GET /transactions/{id}/pdf

Parameters ​

ParameterType
reqRequestWithToken
resResponse

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() ​

ts
updateTransaction(req, res): Promise<void>;

PATCH /transactions/

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - The requested transaction entity

Operation Id ​

updateTransaction

Tags ​

transactions - Operations of transaction controller

Security ​

JWT


validateTransaction() ​

ts
validateTransaction(req, res): Promise<void>;

POST /transactions/validate

Parameters ​

ParameterType
reqRequestWithToken
resResponse

Returns ​

Promise<void>

200 - Transaction validated

Operation Id ​

validateTransaction

Tags ​

transactions - Operations of the transaction controller

Security ​

JWT


filterRelation() ​

ts
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 ​

ParameterTypeDescription
reqRequestWithTokenExpress request with user token and filters in query params.

Returns ​

Promise<"all" | "organ" | "own">

'own' | 'organ' | 'all'


getRelation() ​

ts
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 ​

ParameterTypeDescription
reqRequestWithTokenRequest with transaction id as param

Returns ​

Promise<string>

whether transaction is connected to user token


postRelation() ​

ts
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 ​

ParameterTypeDescription
reqRequestWithTokenRequest with TransactionRequest in the body

Returns ​

Promise<string>

whether transaction is connected to user token