feat(tbank): add brokerage account summaries

This commit is contained in:
2026-08-26 20:57:55 +03:00
parent 84fabd264f
commit e489d45f88
7 changed files with 240 additions and 19 deletions
+16 -1
View File
@@ -26,9 +26,24 @@ export class TbankAccessService {
) {}
async listSupportedAccounts(userId: string): Promise<BrokerageAccountDto[]> {
return this.withSupportedAccounts(userId, ({ accounts }) => accounts);
}
async withSupportedAccounts<T>(
userId: string,
handler: (context: {
token: string;
accounts: BrokerageAccountDto[];
}) => Promise<T> | T,
): Promise<T> {
const { token } = await this.connection(userId);
return this.tokens.translateInvalidToken(async () =>
supportedTbankAccounts(await this.tbank.getOpenAccounts(token)),
handler({
token,
accounts: supportedTbankAccounts(
await this.tbank.getOpenAccounts(token),
),
}),
);
}