fix ESG chassis inquiry payload

This commit is contained in:
SepehrYahyaee
2026-09-19 16:50:34 +03:30
parent b4c1d7bd5f
commit 4ef53f2cc9
8 changed files with 12 additions and 13 deletions

1
.gitignore vendored
View File

@@ -186,4 +186,3 @@ dist
*.sh
!scripts/fanavaran-flow-test.sh
!scripts/fanavaran-auth.sh
*.json

View File

@@ -446,7 +446,7 @@ curl -X POST "$ESG_URL/inquiry/carByChassis" \
-H "Accept: application/json" \
--data '{
"nationalCode": "0012345678",
"chassis": "NAAR03HFFRDE07024"
"chassisNo": "NAAR03HFFRDE07024"
}'
```

View File

@@ -359,7 +359,7 @@
<table>
<tr><th style="width:70px">متد</th><th>مسیر</th><th>توضیح</th></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/policyByPlate</code></td><td>جستجوی بیمه‌نامه مبتنی بر پلاک (THIRD_PARTY). بدنه: <code>nationalCode</code>، <code>plk1–plk4</code>. پاسخ قبل از ذخیره به فرمت قدیمی تجارت نگاشت می‌شود.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/carByChassis</code></td><td>جایگزین دوعاملی VIN/شاسی برای استعلام پلاک. توسط اندپوینت‌های <code>run-inquiries-vin</code> فراخوانی می‌شود. بدنه: <code>nationalCode</code>، <code>chassis</code>. مسیر تک‌عاملی <code>policyByChassis</code> استفاده نمی‌شود، چون فیلد <code>nationalCode</code> را نمی‌پذیرد.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/carByChassis</code></td><td>جایگزین دوعاملی VIN/شاسی برای استعلام پلاک. توسط اندپوینت‌های <code>run-inquiries-vin</code> فراخوانی می‌شود. بدنه: <code>nationalCode</code>، <code>chassisNo</code>. مسیر تک‌عاملی <code>policyByChassis</code> استفاده نمی‌شود، چون فیلد <code>nationalCode</code> را نمی‌پذیرد.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/person</code></td><td>بررسی هویت شخصی. بدنه: <code>nationalCode</code>، <code>birthDate</code> (جلالی، نه میلادی).</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/sheba</code></td><td>اعتبارسنجی شبا / حساب بانکی.</td></tr>
</table>

View File

@@ -356,7 +356,7 @@
<table>
<tr><th style="width:70px">Method</th><th>Path</th><th>What it does</th></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/policyByPlate</code></td><td>Plate-based policy lookup (THIRD_PARTY). Body: <code>nationalCode</code>, <code>plk1–plk4</code>. Response is mapped to the old Tejarat format before being stored.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/carByChassis</code></td><td>Two-factor VIN/chassis alternative to the plate inquiry. Called by <code>run-inquiries-vin</code> endpoints. Body: <code>nationalCode</code>, <code>chassis</code>. The one-factor <code>policyByChassis</code> route is not used because it rejects <code>nationalCode</code>.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/carByChassis</code></td><td>Two-factor VIN/chassis alternative to the plate inquiry. Called by <code>run-inquiries-vin</code> endpoints. Body: <code>nationalCode</code>, <code>chassisNo</code>. The one-factor <code>policyByChassis</code> route is not used because it rejects <code>nationalCode</code>.</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/person</code></td><td>Personal identity check. Body: <code>nationalCode</code>, <code>birthDate</code> (Jalali, NOT Gregorian).</td></tr>
<tr><td><span class="method post">POST</span></td><td><code>/inquiry/sheba</code></td><td>Sheba / bank account validation.</td></tr>
</table>

View File

@@ -159,7 +159,7 @@ describe("RequestManagementService policyholder inquiry routing", () => {
).toHaveBeenCalledWith(
{
nationalCode: "0022222222",
chassis: vehicle.vin,
chassisNo: vehicle.vin,
},
undefined,
);

View File

@@ -468,7 +468,7 @@ export class RequestManagementService {
const result = await this.sandHubService.getCarByChassisInquiry(
{
nationalCode: subjects.thirdPartyPolicyNationalCode,
chassis,
chassisNo: chassis,
},
options,
);

View File

@@ -191,7 +191,7 @@ describe("SandHubService inquiry mocks", () => {
const result = await service.getCarByChassisInquiry({
nationalCode: "0012345678",
chassis: "NAAR03HFFRDE07024",
chassisNo: "NAAR03HFFRDE07024",
});
expect(result.mapped.Error.Message).toBe(
@@ -242,7 +242,7 @@ describe("SandHubService inquiry mocks", () => {
service.getCarByChassisInquiry(
{
nationalCode: "1234567890",
chassis: "NAAR03HFFRDE07024",
chassisNo: "NAAR03HFFRDE07024",
},
{ enforceDeploymentClientMatch: true },
),
@@ -258,14 +258,14 @@ describe("SandHubService inquiry mocks", () => {
await service.getCarByChassisInquiry({
nationalCode: "0012345678",
chassis: "NAAR03HFFRDE07024",
chassisNo: "NAAR03HFFRDE07024",
});
expect(esg).toHaveBeenCalledWith(
expect.stringContaining("/inquiry/carByChassis"),
{
nationalCode: "0012345678",
chassis: "NAAR03HFFRDE07024",
chassisNo: "NAAR03HFFRDE07024",
},
"vinChassis",
undefined,

View File

@@ -1197,14 +1197,14 @@ export class SandHubService {
* @param options - optional per-tenant client scope
*/
async getCarByChassisInquiry(
identity: { nationalCode: string; chassis: string },
identity: { nationalCode: string; 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/carByChassis`;
const requestPayload = {
nationalCode: String(identity.nationalCode),
chassis: String(identity.chassis),
chassisNo: String(identity.chassisNo),
};
const live = await this.isInquiryLive("vinChassis", options);
@@ -1213,7 +1213,7 @@ export class SandHubService {
const ctx = await this.mockCompanyContext(options);
const raw = this.buildMockPlateInquiryRaw(ctx);
this.logger.debug(
`[MOCK] getCarByChassisInquiry nationalCode=${identity.nationalCode} chassis=${identity.chassis}`,
`[MOCK] getCarByChassisInquiry nationalCode=${identity.nationalCode} chassisNo=${identity.chassisNo}`,
);
const mapped = this.mapEsgPolicyByPlateToOldFormat(raw, "thirdPartyVin");
if (!mapped?.Error) {