From 4e3e09e257b2ceb751b605c01d6e5150ac4068ad Mon Sep 17 00:00:00 2001 From: Rinat Arsaev <11846445+A77AY@users.noreply.github.com> Date: Mon, 13 May 2024 20:33:18 +0500 Subject: [PATCH] IMP-230: Init tariffs api (#358) --- package-lock.json | 6 +++ package.json | 1 + src/app/api/dominator/dominator.service.ts | 57 +++++++++++++++++++++ src/app/api/dominator/index.ts | 1 + src/app/sections/claim/claim.component.html | 4 +- 5 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/app/api/dominator/dominator.service.ts create mode 100644 src/app/api/dominator/index.ts diff --git a/package-lock.json b/package-lock.json index 0e6d5852..97af5ad4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "@ngneat/input-mask": "6.0.0", "@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/domain-proto": "2.0.1-b04aba8.0", + "@vality/dominator-proto": "1.0.0", "@vality/fistful-proto": "2.0.1-6600be9.0", "@vality/machinegun-proto": "1.0.0", "@vality/magista-proto": "2.0.2-28d11b9.0", @@ -6421,6 +6422,11 @@ "resolved": "https://registry.npmjs.org/@vality/domain-proto/-/domain-proto-2.0.1-b04aba8.0.tgz", "integrity": "sha512-AKD5RkqiS+31hTUaLfh7I3vgYZ2yytwxp8J1jQZ7iPWURz/m5+6Yg4YKNj8Vyyxu3yzO13FxxPUnkTh/poCDWg==" }, + "node_modules/@vality/dominator-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@vality/dominator-proto/-/dominator-proto-1.0.0.tgz", + "integrity": "sha512-N7gTGnr419mwnZH3FB4kTIJUgbFoVzKUHKNIyzjjJuPiSnOEaWr/sj8cFfDdyuHUkpHb4CKXJ+QdF686UtGKGw==" + }, "node_modules/@vality/eslint-config": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/@vality/eslint-config/-/eslint-config-8.2.0.tgz", diff --git a/package.json b/package.json index 43638a58..4b8fee72 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ "@ngneat/input-mask": "6.0.0", "@vality/deanonimus-proto": "2.0.1-2a02d87.0", "@vality/domain-proto": "2.0.1-b04aba8.0", + "@vality/dominator-proto": "1.0.0", "@vality/fistful-proto": "2.0.1-6600be9.0", "@vality/machinegun-proto": "1.0.0", "@vality/magista-proto": "2.0.2-28d11b9.0", diff --git a/src/app/api/dominator/dominator.service.ts b/src/app/api/dominator/dominator.service.ts new file mode 100644 index 00000000..d0ce6b7d --- /dev/null +++ b/src/app/api/dominator/dominator.service.ts @@ -0,0 +1,57 @@ +import { Injectable } from '@angular/core'; +import { + dominator_DominatorServiceCodegenClient, + ThriftAstMetadata, + dominator_DominatorService, + dominator, +} from '@vality/dominator-proto'; +import { combineLatest, from, map, Observable, switchMap } from 'rxjs'; + +import { KeycloakTokenInfoService, toWachterHeaders } from '@cc/app/shared/services'; +import { environment } from '@cc/environments/environment'; + +import { ConfigService } from '../../core/config.service'; + +@Injectable({ providedIn: 'root' }) +export class DominatorService { + private client$: Observable; + + constructor( + private keycloakTokenInfoService: KeycloakTokenInfoService, + configService: ConfigService, + ) { + const headers$ = this.keycloakTokenInfoService.info$.pipe( + map(toWachterHeaders('Dominator')), + ); + const metadata$ = from( + import('@vality/fistful-proto/metadata.json').then( + (m) => m.default as ThriftAstMetadata[], + ), + ); + this.client$ = combineLatest([metadata$, headers$]).pipe( + switchMap(([metadata, headers]) => + dominator_DominatorService({ + metadata, + headers, + logging: environment.logging.requests, + ...configService.config.api.wachter, + }), + ), + ); + } + + // eslint-disable-next-line @typescript-eslint/naming-convention + SearchShopTermSets(shopSearchQuery: dominator.ShopSearchQuery) { + return this.client$.pipe(switchMap((c) => c.SearchShopTermSets(shopSearchQuery))); + } + + // eslint-disable-next-line @typescript-eslint/naming-convention + SearchWalletTermSets(walletSearchQuery: dominator.WalletSearchQuery) { + return this.client$.pipe(switchMap((c) => c.SearchWalletTermSets(walletSearchQuery))); + } + + // eslint-disable-next-line @typescript-eslint/naming-convention + SearchTerminalTermSets(terminalSearchQuery: dominator.TerminalSearchQuery) { + return this.client$.pipe(switchMap((c) => c.SearchTerminalTermSets(terminalSearchQuery))); + } +} diff --git a/src/app/api/dominator/index.ts b/src/app/api/dominator/index.ts new file mode 100644 index 00000000..fa1320d9 --- /dev/null +++ b/src/app/api/dominator/index.ts @@ -0,0 +1 @@ +export * from './dominator.service'; diff --git a/src/app/sections/claim/claim.component.html b/src/app/sections/claim/claim.component.html index f47a98c7..4461d477 100644 --- a/src/app/sections/claim/claim.component.html +++ b/src/app/sections/claim/claim.component.html @@ -36,7 +36,7 @@ >