feat: disconnect and update bank account

This commit is contained in:
Ahmed Bouhuolia
2024-07-16 17:09:00 +02:00
parent fa7e6b1fca
commit c2815afbe3
11 changed files with 246 additions and 29 deletions

View File

@@ -22,8 +22,9 @@ export class BankAccountsController extends BaseController {
router.get('/:bankAccountId/meta', this.getBankAccountSummary.bind(this));
router.post(
'/:bankAccountId/disconnect',
this.discountBankAccount.bind(this)
this.disconnectBankAccount.bind(this)
);
router.post('/:bankAccountId/update', this.refreshBankAccount.bind(this));
return router;
}
@@ -81,4 +82,31 @@ export class BankAccountsController extends BaseController {
next(error);
}
}
/**
* Refresh the given bank account.
* @param {Request} req
* @param {Response} res
* @param {NextFunction} next
* @returns {Promise<Response|null>}
*/
async refreshBankAccount(
req: Request<{ bankAccountId: number }>,
res: Response,
next: NextFunction
) {
const { bankAccountId } = req.params;
const { tenantId } = req;
try {
await this.bankAccountsApp.refreshBankAccount(tenantId, bankAccountId);
return res.status(200).send({
id: bankAccountId,
message: 'The bank account has been disconnected.',
});
} catch (error) {
next(error);
}
}
}