refactor: refactor future event list
This commit is contained in:
@@ -45,6 +45,11 @@ export type TbankPortfolio = {
|
||||
};
|
||||
export type TbankPositions = { money?: TbankMoney[] };
|
||||
export type TbankInstrument = { ticker?: string; name?: string; isin?: string };
|
||||
export type TbankDividend = {
|
||||
dividendNet?: TbankMoney;
|
||||
recordDate?: TbankTimestamp;
|
||||
dividendType?: string;
|
||||
};
|
||||
export type TbankTimestamp = { seconds?: string | number; nanos?: number };
|
||||
export type TbankOperationItem = {
|
||||
cursor?: string;
|
||||
@@ -229,6 +234,21 @@ export class TbankClient {
|
||||
);
|
||||
}
|
||||
|
||||
getDividends(
|
||||
token: string,
|
||||
instrumentId: string,
|
||||
from: string,
|
||||
to: string,
|
||||
): Promise<TbankDividend[]> {
|
||||
return this.call(token, this.instruments, 'getDividends', {
|
||||
instrumentId,
|
||||
from: { seconds: String(utcSeconds(from)) },
|
||||
to: { seconds: String(utcSeconds(to)) },
|
||||
}).then(
|
||||
(response: { dividends?: TbankDividend[] }) => response.dividends ?? [],
|
||||
);
|
||||
}
|
||||
|
||||
private async call<Response>(
|
||||
token: string,
|
||||
client: TbankClientService,
|
||||
@@ -307,3 +327,7 @@ export class TbankClient {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function utcSeconds(date: string): number {
|
||||
return Math.floor(Date.parse(`${date}T00:00:00Z`) / 1000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user