forked from Yara724/api
Compare commits
6
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa2b1972a2 | ||
|
|
846355a32f | ||
|
|
340ed5e9b3 | ||
|
|
e4b342cd25 | ||
|
|
2cdf4aba02 | ||
|
|
e7236884db |
@@ -11,7 +11,7 @@ source: fanavaran-module-docs
|
||||
1. `FANAVARAN_CLIENT=parsian` (or target tenant)
|
||||
2. Valid tenant credentials in Mongo / seed
|
||||
3. `INSURANCE_CORP_ID` matching that tenant’s insurance-corp Caption
|
||||
4. Network access to `apimanager.iraneit.com`
|
||||
4. Network access to the tenant host (`api.inssw.ir` for Moallem; `apimanager.iraneit.com` for Parsian / Tejaratno)
|
||||
5. Optional: warm lookups via first `GET /lookups/fanavaran/{name}` or auth script
|
||||
|
||||
## Auth smoke test
|
||||
@@ -52,6 +52,16 @@ Fill **section A** before the first run:
|
||||
|
||||
Lookup ids from Tejaratno/Parsian files are invalid for Moallem (Fanavaran returns `نوع خودرو یافت نشد` and similar). Fetch Moallem lookups first (`GET /lookups/vehicle-kinds` with `FANAVARAN_CLIENT=moallem`, or curl Fanavaran with that tenant’s token).
|
||||
|
||||
For Moallem V14, keep `FANAVARAN_API_VERSION=v14`. The script retains the V14 `AnnouncementDate` field and embeds a `DmgNotifications` item in the GEN.03 request. Fill `CLAIM_NOTIFICATION_DATE`, `NOTIFIER_TYPE_ID`, `NOTIFIER_RELATION_ID`, and `NOTIFIER_PARTY_ID` with Moallem values; the type and relation IDs must come from Moallem's own lookups. This is a live contract probe for Moallem's V14 endpoint. It does not call the V15-only GEN.30 endpoint.
|
||||
|
||||
### Browser UI for Moallem V14
|
||||
|
||||
Use the prepared Moallem env file as the UI server's working file:
|
||||
|
||||
FANAVARAN_FLOW_ENV=scripts/data/fanavaran-flow.moallem.env node scripts/fanavaran-flow-ui-server.js
|
||||
|
||||
Open http://127.0.0.1:17824, confirm the client is moallem and API version is v14, then refresh Moallem's tenant lookups. The notifier form is available for Moallem V14; enter the reporting party's national code and birth date, inquire the party, and select Moallem's notifier type and relation. Submitting GEN.03 sends the V14 body plus the embedded notifier.
|
||||
|
||||
### 2. Network / IP whitelist
|
||||
|
||||
Fanavaran Login is IP-restricted. From a **whitelisted server**, run with no proxy. From **localhost**, Termius dynamic port forwarding does **not** apply automatically — set:
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
# V14 (Parsian / Moallem) vs Fanavaran V15.00 (Tejaratno)
|
||||
|
||||
V15.00 is the product package. HTTP paths stay `/Api/BimeApi/v2.0/car/...`. There is no `/v15` URL. Auth headers are unchanged (`authenticationToken`, `CorpId`, `ContractId`, `Location`).
|
||||
|
||||
**Tejaratno third-party GEN.03 uses V15.** Parsian and Moallem stay on the V14 body in [third-party-stage-fields.md](./third-party-stage-fields.md). Tejaratno car-body (hull) is not this contract.
|
||||
|
||||
Field tables live in the `fanavaran-api-v15` skill. The live transformer is `src/claim-request-management/fanavaran-v15-third-party-base.ts`.
|
||||
|
||||
## Who sends which GEN.03
|
||||
|
||||
| Tenant | Product | Body |
|
||||
|--------|---------|------|
|
||||
| Tejaratno | ثالث | V15 allowlist, no `AnnouncementDate`, one nested `DmgNotifications[]` item |
|
||||
| Tejaratno | بدنه | Existing hull whitelist. Notifier type/relation are copied onto the hull root only |
|
||||
| Parsian, Moallem | ثالث and بدنه | V14, including `AnnouncementDate = AccidentDate` |
|
||||
|
||||
GEN.12, GEN.07, and GEN.08 are the same URLs and JSON for every tenant. Do not switch Tejaratno attachments to GEN.02.
|
||||
|
||||
## Tejaratno third-party create
|
||||
|
||||
Same staged path as Parsian: GEN.03 base → GEN.12 damage → GEN.07 files (`FileName` / `FileTypeId`) → GEN.08 expertise.
|
||||
|
||||
GEN.03 omits `AnnouncementDate` (still an output). It also omits the V14 keys that are not in the V15 input table: `ActualPremium`, `ArchiveNo`, `AuthorityCulpritId`, `ClaimCompletionDate`, `CostSeparationToDmgSections`, `CustomerFaultPercent`, `GlassBreakReasonId`, `IsOwnerChanged`, `IsSurplusArticleEighthLaw`, `StatusChangeDate`. Do not send `ComplementClaimId`.
|
||||
|
||||
One `DmgNotifications` item is always nested on create. Fanavaran rejects a financial claim with no approved announcer (`PrvMustHaveAnyElamKhesaratWithTaeedStateRuleBL`). Do not POST GEN.30 before the claim exists. GEN.30 (`.../{ClaimId}/dmg-notifications`) is only an extra announcement after `claimId` exists.
|
||||
|
||||
| Notification field | Value on Tejaratno ثالث |
|
||||
|--|--|
|
||||
| `LetterNo`, `Desc`, `IsInjuredPartyIdentified`, `InjuredPartyId` | `null` |
|
||||
| `ClaimNotificationDate`, `LetterDate` | accident date |
|
||||
| `InjuredCount`, `DeathCount` | JSON `null`, never `0` (`FotCountAndMasdumCountMustBeReadOnlyWhenPrvIsSMPrvRuleBL`; counts are only for bodily / driver-accident files) |
|
||||
| `NotifierTypeId`, `NotifierRelationId` | expert review, ids from the `lookups` collection |
|
||||
| `NotifierPartyId` | guilty insurer |
|
||||
|
||||
`NotifierPartyId` is resolved at preview/submit, not chosen on the review form. Parties inquiry prefers RoleId **161** (بیمهگذار), then **166** (سایر). If neither exists, YARA registers the person with GEN.44 `common/other-people`. Mobile is required (`MobileIsRequiredRule`). Submit throws `FANAVARAN_NOTIFIER_PARTY_REQUIRED` when that id cannot be resolved. Preview still returns the body with a null party id.
|
||||
|
||||
Expert review must pick both notifier ids before the first submit (`FANAVARAN_NOTIFIER_REVIEW_REQUIRED`). Options come from Mongo `lookups` documents `notifier-type` and `notifier-relation` (`response` is `{Id, Caption, IsActive}[]`). Those two names are not fetched from Fanavaran. `common/code-list/notifier-type` 404s; the published paths are `car/code-list/notifier-type` (VHUP GEN.45) and `car/code-list/notifier-relation` (VHUP GEN.44). The stored Tejaratno type list includes **5518** (مرجع و یا نهاد رسمی) as well as 5516 and 5517. If either document is missing, the review options are empty and submit stays blocked.
|
||||
|
||||
After a successful create, `fanavaranSync.baseClaim.lastPayload` is the V15 body, so later review reads `NotifierTypeId` / `NotifierRelationId` from `DmgNotifications[0]` as well as the claim root.
|
||||
|
||||
## Unchanged stages
|
||||
|
||||
| Stage | URL | What YARA sends |
|
||||
|-------|-----|-----------------|
|
||||
| GEN.12 damage case | `.../third-party-car-financial-claims/{claimId}/dmg-cases` | Same input as V14 (driver, owner, plaque, policy, licence, `Desc`, `EstimateAmount`, `PolicyCINumber`, `BuiltYear`, `AccidentVehicleUsedId`). Output may include `Status` (`car/code-list/dmg-case-status`) |
|
||||
| GEN.07 files | `.../{claimId}/files` | `FileName`, `FileTypeId`. This is the staged upload |
|
||||
| GEN.08 expertise | `.../{claimId}/expertise` | Same create body (`DmgCaseId`, wages, `DmgSections[]`, `DropAmountStatus`, `ComponentReplacementTaxAndToll`, `DamagedVehicleCurrentPrice`) |
|
||||
| GEN.09 / GEN.13 | damaged points / price drop | GET-only. YARA does not call them |
|
||||
|
||||
GEN.02 is the import-claim file service (`third-party-car-import-claims/{PrvId}/files`, `Title` + `FileType`). It is not the attachment API.
|
||||
|
||||
`DriverId` / `OwnerId` still come from parties inquiry (161 then 166) and GEN.44 when the person is missing. V15 documents those ids against `common/other-people`; the inquiry rule stays.
|
||||
|
||||
On expertise read, `HasDropAmount` is an ans lookup, and the output may include `DropAmounts[]`. GEN.13 returns `AccidentLevel`, `DropAmountRates`, and `AccidentRate`. None of that changes the create body.
|
||||
@@ -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(
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
export type FanavaranClientKey = "parsian" | "tejaratno" | "moallem";
|
||||
|
||||
const FANAVARAN_API_ROOTS: Record<FanavaranClientKey, string> = {
|
||||
parsian: "https://apimanager.iraneit.com/BimeApiManager/api",
|
||||
tejaratno: "https://apimanager.iraneit.com/BimeApiManager/api",
|
||||
moallem: "https://api.inssw.ir/BimeApiManager/api",
|
||||
};
|
||||
|
||||
export function getFanavaranApiRoot(clientKey: FanavaranClientKey): string {
|
||||
return FANAVARAN_API_ROOTS[clientKey];
|
||||
}
|
||||
|
||||
export function getFanavaranLookupBaseUrl(
|
||||
clientKey: FanavaranClientKey,
|
||||
): string {
|
||||
return `${getFanavaranApiRoot(clientKey)}/BimeApi/v2.0`;
|
||||
}
|
||||
|
||||
export const FANAVARAN_CLIENT_KEYS: readonly FanavaranClientKey[] = [
|
||||
"parsian",
|
||||
"tejaratno",
|
||||
|
||||
@@ -11,6 +11,7 @@ import { isAxiosError } from "axios";
|
||||
import { Model } from "mongoose";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import {
|
||||
getFanavaranApiRoot,
|
||||
getFanavaranClientProfile,
|
||||
type FanavaranAuthConfig,
|
||||
type FanavaranClientKey,
|
||||
@@ -44,10 +45,13 @@ interface TenantBackoffState {
|
||||
export class FanavaranAuthService {
|
||||
private readonly logger = new Logger(FanavaranAuthService.name);
|
||||
|
||||
private readonly getAppTokenUrl =
|
||||
"https://apimanager.iraneit.com/BimeApiManager/api/EITAuthentication/GetAppToken";
|
||||
private readonly loginUrl =
|
||||
"https://apimanager.iraneit.com/BimeApiManager/api/EITAuthentication/Login";
|
||||
private getAppTokenUrl(clientKey: FanavaranClientKey): string {
|
||||
return `${getFanavaranApiRoot(clientKey)}/EITAuthentication/GetAppToken`;
|
||||
}
|
||||
|
||||
private loginUrl(clientKey: FanavaranClientKey): string {
|
||||
return `${getFanavaranApiRoot(clientKey)}/EITAuthentication/Login`;
|
||||
}
|
||||
|
||||
/** When Fanavaran says "try again later", pause all tenant calls. */
|
||||
static readonly TRANSIENT_BACKOFF_MS = 5 * 60 * 1000;
|
||||
@@ -181,8 +185,12 @@ export class FanavaranAuthService {
|
||||
* Stable fingerprint of tenant auth. Any change (location, credentials, …)
|
||||
* forces a fresh GetAppToken+Login even before Tehran midnight.
|
||||
*/
|
||||
static authFingerprint(auth: FanavaranAuthConfig): string {
|
||||
static authFingerprint(
|
||||
clientKey: FanavaranClientKey,
|
||||
auth: FanavaranAuthConfig,
|
||||
): string {
|
||||
return [
|
||||
getFanavaranApiRoot(clientKey),
|
||||
auth.appName,
|
||||
auth.secret,
|
||||
auth.username,
|
||||
@@ -211,6 +219,7 @@ export class FanavaranAuthService {
|
||||
): Promise<string> {
|
||||
this.assertNotInBackoff(clientKey);
|
||||
const fingerprint = FanavaranAuthService.authFingerprint(
|
||||
clientKey,
|
||||
getFanavaranClientProfile(clientKey).auth,
|
||||
);
|
||||
|
||||
@@ -277,9 +286,17 @@ export class FanavaranAuthService {
|
||||
auditSession?: FanavaranAuditSession,
|
||||
): Promise<string> {
|
||||
const profile = getFanavaranClientProfile(clientKey);
|
||||
const fingerprint = FanavaranAuthService.authFingerprint(profile.auth);
|
||||
const appToken = await this.fetchAppToken(profile.auth, auditSession);
|
||||
const fingerprint = FanavaranAuthService.authFingerprint(
|
||||
clientKey,
|
||||
profile.auth,
|
||||
);
|
||||
const appToken = await this.fetchAppToken(
|
||||
clientKey,
|
||||
profile.auth,
|
||||
auditSession,
|
||||
);
|
||||
const authenticationToken = await this.fetchLoginToken(
|
||||
clientKey,
|
||||
appToken,
|
||||
profile.auth,
|
||||
auditSession,
|
||||
@@ -413,9 +430,11 @@ export class FanavaranAuthService {
|
||||
}
|
||||
|
||||
private async fetchAppToken(
|
||||
clientKey: FanavaranClientKey,
|
||||
config: Pick<FanavaranAuthConfig, "appName" | "secret">,
|
||||
auditSession?: FanavaranAuditSession,
|
||||
): Promise<string> {
|
||||
const url = this.getAppTokenUrl(clientKey);
|
||||
const startedAt = Date.now();
|
||||
const requestHeaders = {
|
||||
appname: config.appName,
|
||||
@@ -427,7 +446,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.GET_APP_TOKEN,
|
||||
status: FanavaranAuditStatus.STARTED,
|
||||
requestUrl: this.getAppTokenUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
requestHeaders,
|
||||
requestBody: "",
|
||||
@@ -437,7 +456,7 @@ export class FanavaranAuthService {
|
||||
|
||||
try {
|
||||
const response = await firstValueFrom(
|
||||
this.httpService.post(this.getAppTokenUrl, "", {
|
||||
this.httpService.post(url, "", {
|
||||
headers: requestHeaders,
|
||||
transformRequest: this.emptyBodyTransformRequest(),
|
||||
}),
|
||||
@@ -462,7 +481,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.GET_APP_TOKEN,
|
||||
status: FanavaranAuditStatus.SUCCESS,
|
||||
requestUrl: this.getAppTokenUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
httpStatus: response.status,
|
||||
requestHeaders: exchange.requestHeaders,
|
||||
@@ -485,7 +504,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.GET_APP_TOKEN,
|
||||
status: FanavaranAuditStatus.FAILURE,
|
||||
requestUrl: this.getAppTokenUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
httpStatus: exchange.httpStatus,
|
||||
requestHeaders: exchange.requestHeaders,
|
||||
@@ -506,10 +525,12 @@ export class FanavaranAuthService {
|
||||
}
|
||||
|
||||
private async fetchLoginToken(
|
||||
clientKey: FanavaranClientKey,
|
||||
appToken: string,
|
||||
config: Pick<FanavaranAuthConfig, "username" | "password">,
|
||||
auditSession?: FanavaranAuditSession,
|
||||
): Promise<string> {
|
||||
const url = this.loginUrl(clientKey);
|
||||
const startedAt = Date.now();
|
||||
const requestHeaders = {
|
||||
appToken,
|
||||
@@ -522,7 +543,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.LOGIN,
|
||||
status: FanavaranAuditStatus.STARTED,
|
||||
requestUrl: this.loginUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
requestHeaders,
|
||||
requestBody: "",
|
||||
@@ -532,7 +553,7 @@ export class FanavaranAuthService {
|
||||
|
||||
try {
|
||||
const response = await firstValueFrom(
|
||||
this.httpService.post(this.loginUrl, "", {
|
||||
this.httpService.post(url, "", {
|
||||
headers: requestHeaders,
|
||||
transformRequest: this.emptyBodyTransformRequest(),
|
||||
}),
|
||||
@@ -562,7 +583,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.LOGIN,
|
||||
status: FanavaranAuditStatus.SUCCESS,
|
||||
requestUrl: this.loginUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
httpStatus: response.status,
|
||||
requestHeaders: exchange.requestHeaders,
|
||||
@@ -588,7 +609,7 @@ export class FanavaranAuthService {
|
||||
session: auditSession,
|
||||
step: FanavaranAuditStep.LOGIN,
|
||||
status: FanavaranAuditStatus.FAILURE,
|
||||
requestUrl: this.loginUrl,
|
||||
requestUrl: url,
|
||||
requestMethod: "POST",
|
||||
httpStatus: exchange.httpStatus,
|
||||
requestHeaders: exchange.requestHeaders,
|
||||
|
||||
@@ -71,6 +71,7 @@ export class FanavaranClientConfigService implements OnModuleInit {
|
||||
previousFingerprints.set(
|
||||
key,
|
||||
FanavaranAuthService.authFingerprint(
|
||||
key,
|
||||
getFanavaranClientProfile(key).auth,
|
||||
),
|
||||
);
|
||||
@@ -110,7 +111,10 @@ export class FanavaranClientConfigService implements OnModuleInit {
|
||||
setFanavaranClientProfilesCache(cache);
|
||||
|
||||
for (const key of FANAVARAN_CLIENT_KEYS) {
|
||||
const next = FanavaranAuthService.authFingerprint(cache[key]!.auth);
|
||||
const next = FanavaranAuthService.authFingerprint(
|
||||
key,
|
||||
cache[key]!.auth,
|
||||
);
|
||||
const prev = previousFingerprints.get(key);
|
||||
if (prev && prev !== next) {
|
||||
this.logger.warn(
|
||||
|
||||
@@ -11,7 +11,10 @@ import { InjectModel } from "@nestjs/mongoose";
|
||||
import { Model } from "mongoose";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
import { isAxiosError } from "axios";
|
||||
import { type FanavaranClientKey } from "src/core/config/fanavaran-client.config";
|
||||
import {
|
||||
getFanavaranLookupBaseUrl,
|
||||
type FanavaranClientKey,
|
||||
} from "src/core/config/fanavaran-client.config";
|
||||
import {
|
||||
LookupModel,
|
||||
type LookupDocument,
|
||||
@@ -184,7 +187,11 @@ export class FanavaranLookupService {
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await this.fetchFromFanavaran(clientKey, url);
|
||||
const tenantUrl = url.replace(
|
||||
FANAVARAN_LOOKUP_BASE_URL,
|
||||
getFanavaranLookupBaseUrl(clientKey),
|
||||
);
|
||||
const data = await this.fetchFromFanavaran(clientKey, tenantUrl);
|
||||
await this.writeCacheFile(clientKey, cacheFile, data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
@@ -249,7 +256,7 @@ export class FanavaranLookupService {
|
||||
vin: string,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/inquiry-by-vin?vin=${encodeURIComponent(vin)}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/car/vehicles/inquiry-by-vin?vin=${encodeURIComponent(vin)}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -260,7 +267,7 @@ export class FanavaranLookupService {
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url =
|
||||
`${FANAVARAN_LOOKUP_BASE_URL}/common/Policies/inquiry-my-policies` +
|
||||
`${getFanavaranLookupBaseUrl(clientKey)}/common/Policies/inquiry-my-policies` +
|
||||
`?InsuranceLineId=${insuranceLineId}` +
|
||||
`&NationalCode=${encodeURIComponent(nationalCode)}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
@@ -271,7 +278,7 @@ export class FanavaranLookupService {
|
||||
policyId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/third-party-car-policies/${policyId}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/car/third-party-car-policies/${policyId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -280,7 +287,7 @@ export class FanavaranLookupService {
|
||||
policyId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicle-hull-policies/${policyId}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/car/vehicle-hull-policies/${policyId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -290,7 +297,7 @@ export class FanavaranLookupService {
|
||||
policyId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicle-hull-policies/${policyId}/dmg-accessories`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/car/vehicle-hull-policies/${policyId}/dmg-accessories`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -301,7 +308,7 @@ export class FanavaranLookupService {
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const query = versionNo == null ? "" : `?versionno=${versionNo}`;
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}${query}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/car/vehicles/${vehicleId}${query}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -310,7 +317,7 @@ export class FanavaranLookupService {
|
||||
customerId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/customers/${customerId}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/common/customers/${customerId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
@@ -324,7 +331,7 @@ export class FanavaranLookupService {
|
||||
},
|
||||
): Promise<unknown> {
|
||||
const url =
|
||||
`${FANAVARAN_LOOKUP_BASE_URL}/common/parties/inquiry-by-unique-identifier` +
|
||||
`${getFanavaranLookupBaseUrl(clientKey)}/common/parties/inquiry-by-unique-identifier` +
|
||||
`?NationalCode=${encodeURIComponent(params.nationalCode)}` +
|
||||
`&BirthYear=${params.birthYear}` +
|
||||
`&BirthMonth=${params.birthMonth}` +
|
||||
@@ -336,7 +343,7 @@ export class FanavaranLookupService {
|
||||
clientKey: FanavaranClientKey,
|
||||
personId: number,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/other-people/${personId}`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/common/other-people/${personId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
@@ -344,7 +351,7 @@ export class FanavaranLookupService {
|
||||
clientKey: FanavaranClientKey,
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/other-people`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/common/other-people`;
|
||||
return this.postToFanavaran(clientKey, url, payload);
|
||||
}
|
||||
|
||||
@@ -407,7 +414,7 @@ export class FanavaranLookupService {
|
||||
|
||||
// Try fetching the full list directly from Fanavaran
|
||||
let companies: unknown;
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/insurance-corp`;
|
||||
const url = `${getFanavaranLookupBaseUrl(clientKey)}/common/code-list/insurance-corp`;
|
||||
try {
|
||||
companies = await this.fetchFromFanavaran(clientKey, url);
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user