feat(tbank): add brokerage account summaries
This commit is contained in:
@@ -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),
|
||||
),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user