forked from Yara724/api
YARA-947, YARA-1038
This commit is contained in:
@@ -893,6 +893,48 @@ export class SandHubService {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ESG VIN/chassis-number inquiry (`/inquiry/policyByChassis`).
|
||||
*
|
||||
* When `vinChassis` inquiry is disabled (mock mode) the response shape mirrors
|
||||
* `buildMockPlateInquiryRaw` so the downstream mapper (`mapEsgPolicyByPlateToOldFormat`)
|
||||
* can normalise it into the same `{ raw, mapped }` contract used by the plate path.
|
||||
*
|
||||
* @param chassisNo - 17-character VIN / chassis number
|
||||
* @param options - optional per-tenant client scope
|
||||
*/
|
||||
async getPolicyByChassisInquiry(
|
||||
chassisNo: string,
|
||||
options?: SandHubInquiryOptions,
|
||||
): Promise<{ raw: any; mapped: any }> {
|
||||
const baseUrl = process.env.ESG_URL ?? "http://192.168.20.22:8085";
|
||||
const requestUrl = `${baseUrl}/inquiry/policyByChassis`;
|
||||
const requestPayload = { chassisNo };
|
||||
|
||||
const live = await this.isInquiryLive("vinChassis", options);
|
||||
|
||||
if (!live) {
|
||||
const ctx = await this.mockCompanyContext(options);
|
||||
const raw = this.buildMockPlateInquiryRaw(ctx);
|
||||
this.logger.debug(
|
||||
`[MOCK] getPolicyByChassisInquiry chassisNo=${chassisNo}`,
|
||||
);
|
||||
const mapped = this.mapEsgPolicyByPlateToOldFormat(raw);
|
||||
return { raw, mapped };
|
||||
}
|
||||
|
||||
const raw = await this.makeEsgRequest(
|
||||
requestUrl,
|
||||
requestPayload,
|
||||
"vinChassis",
|
||||
options,
|
||||
);
|
||||
const mapped = this.mapEsgPolicyByPlateToOldFormat(raw);
|
||||
return { raw, mapped };
|
||||
}
|
||||
|
||||
|
||||
private async makeSandHubRequest(
|
||||
url: string,
|
||||
payload: any,
|
||||
|
||||
Reference in New Issue
Block a user