feat(portfolio): store and publish instrument sector and issuer (WealthLedger/main#48) (#148)
This commit was merged in pull request #148.
This commit is contained in:
@@ -375,18 +375,29 @@ export class TbankClient {
|
||||
).then((response) => response.instruments ?? []);
|
||||
}
|
||||
|
||||
getBond(token: string, uid: string): Promise<null | TbankBond> {
|
||||
getBond(token: string, uid: string, idType = InstrumentIdType.Uid, notFound = false): Promise<null | TbankBond> {
|
||||
return this.call<{ instrument?: TbankBond }>(
|
||||
token,
|
||||
this.sparseInstruments,
|
||||
'bondBy',
|
||||
{
|
||||
idType: InstrumentIdType.Uid,
|
||||
idType,
|
||||
id: uid,
|
||||
},
|
||||
notFound,
|
||||
).then((response) => response.instrument ?? null);
|
||||
}
|
||||
|
||||
getEtf(
|
||||
token: string,
|
||||
id: string,
|
||||
idType = InstrumentIdType.Uid,
|
||||
notFound = false,
|
||||
): Promise<null | Pick<TbankShare, 'assetUid' | 'figi' | 'sector' | 'uid'>> {
|
||||
return this.call<{ instrument?: TbankShare }>(token, this.sparseInstruments, 'etfBy', { idType, id }, notFound)
|
||||
.then((response) => response.instrument ?? null);
|
||||
}
|
||||
|
||||
getBondCoupons(
|
||||
token: string,
|
||||
uid: string,
|
||||
@@ -405,18 +416,25 @@ export class TbankClient {
|
||||
).then((response) => response.events ?? []);
|
||||
}
|
||||
|
||||
getShare(token: string, uid: string): Promise<null | TbankShare> {
|
||||
getShare(token: string, uid: string, idType = InstrumentIdType.Uid, notFound = false): Promise<null | TbankShare> {
|
||||
return this.call<{ instrument?: TbankShare }>(
|
||||
token,
|
||||
this.instruments,
|
||||
'shareBy',
|
||||
{
|
||||
idType: InstrumentIdType.Uid,
|
||||
idType,
|
||||
id: uid,
|
||||
},
|
||||
notFound,
|
||||
).then((response) => response.instrument ?? null);
|
||||
}
|
||||
|
||||
getAssetBrand(token: string, assetUid: string): Promise<null | { assetUid?: string; brand?: { name?: string; uid?: string } }> {
|
||||
return this.call<{ asset?: { brand?: { name?: string; uid?: string }; uid?: string } }>(
|
||||
token, this.instruments, 'getAssetBy', { id: assetUid }, true,
|
||||
).then((response) => response.asset ? { assetUid: response.asset.uid, brand: response.asset.brand } : null);
|
||||
}
|
||||
|
||||
getAssetDescription(token: string, assetUid: string): Promise<null | string> {
|
||||
return this.call<{ asset?: { description?: string } }>(
|
||||
token,
|
||||
@@ -514,6 +532,7 @@ export class TbankClient {
|
||||
client: TbankClientService,
|
||||
method: string,
|
||||
request: object,
|
||||
notFound = false,
|
||||
): Promise<Response> {
|
||||
const metadataCall = method === 'getInstrumentBy';
|
||||
for (let attempts = FIRST_ATTEMPT; attempts <= RPC_MAX_ATTEMPTS; attempts += ATTEMPT_INCREMENT) {
|
||||
@@ -576,7 +595,7 @@ export class TbankClient {
|
||||
}
|
||||
if (
|
||||
grpcCode === status.NOT_FOUND &&
|
||||
(method === 'shareBy' || metadataCall)
|
||||
(notFound || method === 'shareBy' || metadataCall)
|
||||
) {
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user