forked from Yara724/api
car body policy and sales extended
This commit is contained in:
@@ -251,6 +251,8 @@ export class FanavaranAuthService {
|
||||
forceRefresh?: boolean;
|
||||
/** Per-request Location override (does not affect token fingerprint). */
|
||||
locationOverride?: string;
|
||||
/** Per-request ContractId override (بدنه vs ثالث). Does not affect token fingerprint. */
|
||||
contractIdOverride?: string;
|
||||
},
|
||||
): Promise<{
|
||||
authenticationToken: string;
|
||||
@@ -264,10 +266,11 @@ export class FanavaranAuthService {
|
||||
options,
|
||||
);
|
||||
const locationOverride = options?.locationOverride?.trim();
|
||||
const contractIdOverride = options?.contractIdOverride?.trim();
|
||||
return {
|
||||
authenticationToken,
|
||||
CorpId: profile.auth.corpId,
|
||||
ContractId: profile.auth.contractId,
|
||||
ContractId: contractIdOverride || profile.auth.contractId,
|
||||
Location: locationOverride || profile.auth.location,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -95,6 +95,9 @@ export class FanavaranClientConfigService implements OnModuleInit {
|
||||
password: doc.auth.password,
|
||||
corpId: doc.auth.corpId,
|
||||
contractId: doc.auth.contractId,
|
||||
...(doc.auth.hullContractId
|
||||
? { hullContractId: doc.auth.hullContractId }
|
||||
: {}),
|
||||
location: doc.auth.location,
|
||||
},
|
||||
defaults: { ...doc.defaults },
|
||||
|
||||
@@ -78,9 +78,13 @@ export class FanavaranLookupService {
|
||||
async fetchFromFanavaran(
|
||||
clientKey: FanavaranClientKey,
|
||||
url: string,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
try {
|
||||
const headers = await this.fanavaranAuthService.getRequestHeaders(clientKey);
|
||||
const headers = await this.fanavaranAuthService.getRequestHeaders(
|
||||
clientKey,
|
||||
{ contractIdOverride: options?.contractIdOverride },
|
||||
);
|
||||
|
||||
this.logger.log(
|
||||
`[${clientKey}] Calling Fanavaran lookup API: ${url}`,
|
||||
@@ -236,46 +240,52 @@ export class FanavaranLookupService {
|
||||
async inquiryByVin(
|
||||
clientKey: FanavaranClientKey,
|
||||
vin: string,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/inquiry-by-vin?vin=${encodeURIComponent(vin)}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
async myPolicies(
|
||||
clientKey: FanavaranClientKey,
|
||||
nationalCode: string,
|
||||
insuranceLineId: number = 5,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url =
|
||||
`${FANAVARAN_LOOKUP_BASE_URL}/common/Policies/inquiry-my-policies` +
|
||||
`?InsuranceLineId=${insuranceLineId}` +
|
||||
`&NationalCode=${encodeURIComponent(nationalCode)}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
async thirdPartyPolicyById(
|
||||
clientKey: FanavaranClientKey,
|
||||
policyId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/third-party-car-policies/${policyId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
async bodyPolicyById(
|
||||
clientKey: FanavaranClientKey,
|
||||
policyId: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicle-hull-policies/${policyId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
async vehicleById(
|
||||
clientKey: FanavaranClientKey,
|
||||
vehicleId: number,
|
||||
versionNo: number = 1,
|
||||
versionNo?: number,
|
||||
options?: { contractIdOverride?: string },
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}?versionno=${versionNo}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
const query = versionNo == null ? "" : `?versionno=${versionNo}`;
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}${query}`;
|
||||
return this.fetchFromFanavaran(clientKey, url, options);
|
||||
}
|
||||
|
||||
async customerById(
|
||||
|
||||
@@ -22,6 +22,10 @@ export class FanavaranAuthConfigEmbed {
|
||||
@Prop({ type: String, required: true })
|
||||
contractId: string;
|
||||
|
||||
/** Vehicle-hull (بدنه) ContractId. Optional until the tenant hull line is configured. */
|
||||
@Prop({ type: String, required: false })
|
||||
hullContractId?: string;
|
||||
|
||||
@Prop({ type: String, required: true })
|
||||
location: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user