diff --git a/src/tbank/portfolio.dto.ts b/src/tbank/portfolio.dto.ts index c1063fa..401062b 100644 --- a/src/tbank/portfolio.dto.ts +++ b/src/tbank/portfolio.dto.ts @@ -44,6 +44,9 @@ export class PortfolioPositionDto { @ApiProperty({ type: String, nullable: true }) isin: string | null; + + @ApiProperty({ type: String, nullable: true }) + logoName: string | null; } export class PortfolioDto { diff --git a/src/tbank/portfolio.service.spec.ts b/src/tbank/portfolio.service.spec.ts index e8e36b2..da14570 100644 --- a/src/tbank/portfolio.service.spec.ts +++ b/src/tbank/portfolio.service.spec.ts @@ -92,6 +92,7 @@ describe('PortfolioService', () => { ticker: 'ONE', name: 'Первая позиция', isin: 'RU000A0JX0J2', + brand: { logoName: 'RU000A0JX0J2x160.png' }, }) .mockRejectedValueOnce(new Error('unavailable')); @@ -105,6 +106,7 @@ describe('PortfolioService', () => { currentValue: { currency: 'RUB', value: '6' }, absoluteReturn: { currency: 'RUB', value: '2' }, isin: 'RU000A0JX0J2', + logoName: 'RU000A0JX0J2x160.png', }, { figi: 'TWO', @@ -113,6 +115,7 @@ describe('PortfolioService', () => { quantity: '-0.5', currentValue: { currency: 'USD', value: '-2' }, isin: null, + logoName: null, }, ], cashBalances: [{ currency: 'RUB', value: '1.5' }], @@ -137,7 +140,7 @@ describe('PortfolioService', () => { tbank.getInstrumentByUid.mockResolvedValue({ name: 'Имя по UID' }); await expect(service.get('user', 'account')).resolves.toMatchObject({ - positions: [{ displayName: 'Имя по UID' }], + positions: [{ displayName: 'Имя по UID', logoName: null }], }); expect(tbank.getInstrumentByFigi).not.toHaveBeenCalled(); }); diff --git a/src/tbank/portfolio.service.ts b/src/tbank/portfolio.service.ts index 943853b..f0b3bca 100644 --- a/src/tbank/portfolio.service.ts +++ b/src/tbank/portfolio.service.ts @@ -44,7 +44,12 @@ const types: Record = { type CachedSnapshot = { snapshot: PortfolioDto; storedAt: number }; type CachedMetadata = { - value: { ticker?: string; name?: string; isin?: string } | null; + value: { + ticker?: string; + name?: string; + isin?: string; + brand?: { logoName?: string | null }; + } | null; storedAt: number; }; @@ -210,6 +215,7 @@ export class PortfolioService { averagePurchasePrice, absoluteReturn, isin: metadata?.isin?.trim() || null, + logoName: metadata?.brand?.logoName?.trim() || null, }; } @@ -241,6 +247,7 @@ export class PortfolioService { ticker?: string; name?: string; isin?: string; + brand?: { logoName?: string | null }; } | null>, ) => { const cached = this.metadata.get(key); diff --git a/src/tbank/tbank.client.ts b/src/tbank/tbank.client.ts index ae078e9..04b502d 100644 --- a/src/tbank/tbank.client.ts +++ b/src/tbank/tbank.client.ts @@ -44,7 +44,12 @@ export type TbankPortfolio = { }[]; }; export type TbankPositions = { money?: TbankMoney[] }; -export type TbankInstrument = { ticker?: string; name?: string; isin?: string }; +export type TbankInstrument = { + ticker?: string; + name?: string; + isin?: string; + brand?: { logoName?: string | null }; +}; export type TbankDividend = { dividendNet?: TbankMoney; recordDate?: TbankTimestamp;