urls dynamic integration

This commit is contained in:
2026-10-18 10:20:49 +03:30
parent 47447d1153
commit e7236884db
6 changed files with 103 additions and 44 deletions
@@ -219,6 +219,7 @@ import { HttpService } from "@nestjs/axios";
import { firstValueFrom } from "rxjs";
import {
fanavaranSubmitPath,
getFanavaranLookupBaseUrl,
getFanavaranClientProfile,
resolveFanavaranClientKey,
resolveFanavaranProductContractId,
@@ -228,10 +229,7 @@ import { buildEnrichedDamagedParts } from "src/expert-claim/dto/claim-damaged-pa
import { FanavaranAuditService } from "src/fanavaran/fanavaran-audit.service";
import type { FanavaranAuditSession } from "src/fanavaran/fanavaran-audit.types";
import { FanavaranAuthService } from "src/fanavaran/fanavaran-auth.service";
import {
FANAVARAN_LOOKUP_BASE_URL,
FANAVARAN_REMOTE_LOOKUPS,
} from "src/fanavaran/fanavaran-lookup.config";
import { FANAVARAN_REMOTE_LOOKUPS } from "src/fanavaran/fanavaran-lookup.config";
import { FanavaranLookupService } from "src/fanavaran/fanavaran-lookup.service";
import {
FanavaranAuditSource,
@@ -3306,6 +3304,7 @@ export class ClaimRequestManagementService {
): Promise<string> {
return fanavaranClaimsBaseUrl(
await this.resolveFanavaranClaimProduct(claimCaseId, blameCase),
resolveFanavaranClientKey(),
);
}
@@ -3447,7 +3446,7 @@ export class ClaimRequestManagementService {
(await this.resolveFanavaranClaimProduct(options?.claimCaseId));
const insuranceLineId =
options?.insuranceLineId ?? fanavaranInsuranceLineIdForProduct(product);
const policyInquiryUrl = `https://apimanager.iraneit.com/BimeApiManager/api/BimeApi/v2.0/common/Policies/inquiry-my-policies?InsuranceLineId=${insuranceLineId}&NationalCode=${nationalCodeOfInsurer}`;
const policyInquiryUrl = `${getFanavaranLookupBaseUrl(clientKey)}/common/Policies/inquiry-my-policies?InsuranceLineId=${insuranceLineId}&NationalCode=${nationalCodeOfInsurer}`;
const startedAt = Date.now();
const requestMeta = {
@@ -3821,7 +3820,7 @@ export class ClaimRequestManagementService {
return null;
}
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/other-people`;
const url = `${getFanavaranLookupBaseUrl(clientKey)}/common/other-people`;
const startedAt = Date.now();
const auditSession: FanavaranAuditSession = {
trackingCode: this.fanavaranAuditService.generateTrackingCode(),
@@ -4533,7 +4532,12 @@ export class ClaimRequestManagementService {
claimId: claimCase.claimId ?? null,
dmgCaseId: claimCase.dmgCaseId ?? null,
submitUrl: claimCase.claimId
? fanavaranClaimStageUrl(product, "damage-case", claimCase.claimId)
? fanavaranClaimStageUrl(
product,
"damage-case",
claimCase.claimId,
clientKey,
)
: null,
warning: warnings.length ? warnings.join(" ") : undefined,
payload,
@@ -6111,7 +6115,7 @@ export class ClaimRequestManagementService {
: built,
clientKey,
);
const url = `${fanavaranClaimsBaseUrl("car-body")}/${nestedId}`;
const url = `${fanavaranClaimsBaseUrl("car-body", clientKey)}/${nestedId}`;
this.logger.log(
`[Fanavaran hull sync] PUT ${url} keys=${Object.keys(hull).join(",")}`,
);
@@ -6248,6 +6252,7 @@ export class ClaimRequestManagementService {
product,
"damage-case",
claimCase.claimId,
clientKey,
);
if (url == null) {
this.logger.log(
@@ -1,5 +1,10 @@
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
import { PartyRole } from "src/request-management/entities/schema/partyRole.enum";
import {
getFanavaranLookupBaseUrl,
resolveFanavaranClientKey,
type FanavaranClientKey,
} from "src/core/config/fanavaran-client.config";
import {
FANAVARAN_CAR_BODY_LINE_ID,
FANAVARAN_THIRD_PARTY_LINE_ID,
@@ -12,9 +17,6 @@ import type { InquiryParticipantRoleAssignments } from "src/request-management/i
export type FanavaranClaimProduct = FanavaranCarPolicyProduct;
const FANAVARAN_CLAIMS_HOST =
"https://apimanager.iraneit.com/BimeApiManager/api/BimeApi/v2.0/car";
export function fanavaranClaimProductFromBlameType(
type?: string | null,
): FanavaranClaimProduct {
@@ -44,8 +46,9 @@ export function fanavaranClaimsResourcePath(
export function fanavaranClaimsBaseUrl(
product: FanavaranClaimProduct,
clientKey: FanavaranClientKey = resolveFanavaranClientKey(),
): string {
return `${FANAVARAN_CLAIMS_HOST}/${fanavaranClaimsResourcePath(product)}`;
return `${getFanavaranLookupBaseUrl(clientKey)}/car/${fanavaranClaimsResourcePath(product)}`;
}
export type FanavaranClaimStage =
@@ -66,14 +69,17 @@ export function fanavaranHasDamageCaseStage(
return product === "third-party";
}
export function fanavaranHullImportClaimsUrl(): string {
return `${FANAVARAN_CLAIMS_HOST}/${FANAVARAN_HULL_IMPORT_CLAIMS_PATH}`;
export function fanavaranHullImportClaimsUrl(
clientKey: FanavaranClientKey = resolveFanavaranClientKey(),
): string {
return `${getFanavaranLookupBaseUrl(clientKey)}/car/${FANAVARAN_HULL_IMPORT_CLAIMS_PATH}`;
}
export function fanavaranClaimStageUrl(
product: FanavaranClaimProduct,
stage: FanavaranClaimStage,
claimId: number | string,
clientKey: FanavaranClientKey = resolveFanavaranClientKey(),
): string | null {
if (stage === "damage-case" && !fanavaranHasDamageCaseStage(product)) {
return null;
@@ -89,7 +95,7 @@ export function fanavaranClaimStageUrl(
: stage === "culprits"
? "culprits"
: "expertise";
return `${fanavaranClaimsBaseUrl(product)}/${claimId}/${suffix}`;
return `${fanavaranClaimsBaseUrl(product, clientKey)}/${claimId}/${suffix}`;
}
export function fanavaranInsuranceLineIdForProduct(