forked from Shared/esg
Added car by motor
This commit is contained in:
@@ -13,6 +13,7 @@ export enum InquiryType {
|
|||||||
CAR_PLATE = 'CAR_PLATE_INQUIRY',
|
CAR_PLATE = 'CAR_PLATE_INQUIRY',
|
||||||
CAR_BY_PLATE = 'CAR_BY_PLATE_INQUIRY',
|
CAR_BY_PLATE = 'CAR_BY_PLATE_INQUIRY',
|
||||||
CAR_BY_CHASSIS = 'CAR_BY_CHASSIS_INQUIRY',
|
CAR_BY_CHASSIS = 'CAR_BY_CHASSIS_INQUIRY',
|
||||||
|
CAR_BY_MOTOR = 'CAR_BY_MOTOR_INQUIRY',
|
||||||
THIRD_PARTY_CAR = 'THIRD_PARTY_CAR_INQUIRY',
|
THIRD_PARTY_CAR = 'THIRD_PARTY_CAR_INQUIRY',
|
||||||
POLICY_BY_CHASSIS = 'POLICY_BY_CHASSIS_INQUIRY',
|
POLICY_BY_CHASSIS = 'POLICY_BY_CHASSIS_INQUIRY',
|
||||||
POLICY_BY_PLATE = 'POLICY_BY_PLATE_INQUIRY',
|
POLICY_BY_PLATE = 'POLICY_BY_PLATE_INQUIRY',
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ function parseSoapFields(block: string): Record<string, string> {
|
|||||||
|
|
||||||
export function parseFirstCarPolicy(soapXml: string): Record<string, string> {
|
export function parseFirstCarPolicy(soapXml: string): Record<string, string> {
|
||||||
const resultMatch = soapXml.match(
|
const resultMatch = soapXml.match(
|
||||||
/<(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId)Result[^>]*>([\s\S]*?)<\/(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId)Result>/i,
|
/<(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId|CIIWSPolicyMotor)Result[^>]*>([\s\S]*?)<\/(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId|CIIWSPolicyMotor)Result>/i,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!resultMatch) {
|
if (!resultMatch) {
|
||||||
@@ -82,7 +82,7 @@ export function getCarPolicyProviderError(
|
|||||||
policy: Record<string, string>,
|
policy: Record<string, string>,
|
||||||
): { message: string; code: string; providerCode?: string } | null {
|
): { message: string; code: string; providerCode?: string } | null {
|
||||||
const resultMatch = soapXml.match(
|
const resultMatch = soapXml.match(
|
||||||
/<(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId)Result[^>]*>([\s\S]*?)<\/(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId)Result>/i,
|
/<(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId|CIIWSPolicyMotor)Result[^>]*>([\s\S]*?)<\/(?:[\w]+:)?(?:CIIWSPolicyChassis|CIIWSPolicyVehicleMeli|CIIWSPolicyNationalId|CIIWSPolicyMotor)Result>/i,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (resultMatch) {
|
if (resultMatch) {
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ export default () => ({
|
|||||||
[InquiryType.CAR_PLATE]: buildInquiryRoutingConfig('CAR_PLATE', ProviderName.TEJARATNOU, []),
|
[InquiryType.CAR_PLATE]: buildInquiryRoutingConfig('CAR_PLATE', ProviderName.TEJARATNOU, []),
|
||||||
[InquiryType.CAR_BY_PLATE]: buildInquiryRoutingConfig('CAR_BY_PLATE', ProviderName.PARSIAN, []),
|
[InquiryType.CAR_BY_PLATE]: buildInquiryRoutingConfig('CAR_BY_PLATE', ProviderName.PARSIAN, []),
|
||||||
[InquiryType.CAR_BY_CHASSIS]: buildInquiryRoutingConfig('CAR_BY_CHASSIS', ProviderName.PARSIAN, []),
|
[InquiryType.CAR_BY_CHASSIS]: buildInquiryRoutingConfig('CAR_BY_CHASSIS', ProviderName.PARSIAN, []),
|
||||||
|
[InquiryType.CAR_BY_MOTOR]: buildInquiryRoutingConfig('CAR_BY_MOTOR', ProviderName.PARSIAN, []),
|
||||||
[InquiryType.THIRD_PARTY_CAR]: buildInquiryRoutingConfig('THIRD_PARTY_CAR', ProviderName.PARSIAN, []),
|
[InquiryType.THIRD_PARTY_CAR]: buildInquiryRoutingConfig('THIRD_PARTY_CAR', ProviderName.PARSIAN, []),
|
||||||
[InquiryType.POLICY_BY_CHASSIS]: buildInquiryRoutingConfig(
|
[InquiryType.POLICY_BY_CHASSIS]: buildInquiryRoutingConfig(
|
||||||
'POLICY_BY_CHASSIS',
|
'POLICY_BY_CHASSIS',
|
||||||
@@ -149,6 +150,7 @@ function buildProviderConfig(prefix: string): ProviderEnvConfig {
|
|||||||
InquiryType.CAR_PLATE,
|
InquiryType.CAR_PLATE,
|
||||||
InquiryType.CAR_BY_PLATE,
|
InquiryType.CAR_BY_PLATE,
|
||||||
InquiryType.CAR_BY_CHASSIS,
|
InquiryType.CAR_BY_CHASSIS,
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
InquiryType.THIRD_PARTY_CAR,
|
InquiryType.THIRD_PARTY_CAR,
|
||||||
InquiryType.POLICY_BY_CHASSIS,
|
InquiryType.POLICY_BY_CHASSIS,
|
||||||
InquiryType.POLICY_BY_PLATE,
|
InquiryType.POLICY_BY_PLATE,
|
||||||
@@ -193,6 +195,7 @@ function inquiryTypeToEnvName(inquiryType: InquiryType): string {
|
|||||||
[InquiryType.CAR_PLATE]: 'CAR_PLATE',
|
[InquiryType.CAR_PLATE]: 'CAR_PLATE',
|
||||||
[InquiryType.CAR_BY_PLATE]: 'CAR_BY_PLATE',
|
[InquiryType.CAR_BY_PLATE]: 'CAR_BY_PLATE',
|
||||||
[InquiryType.CAR_BY_CHASSIS]: 'CAR_BY_CHASSIS',
|
[InquiryType.CAR_BY_CHASSIS]: 'CAR_BY_CHASSIS',
|
||||||
|
[InquiryType.CAR_BY_MOTOR]: 'CAR_BY_MOTOR',
|
||||||
[InquiryType.THIRD_PARTY_CAR]: 'THIRD_PARTY_CAR',
|
[InquiryType.THIRD_PARTY_CAR]: 'THIRD_PARTY_CAR',
|
||||||
[InquiryType.POLICY_BY_CHASSIS]: 'POLICY_BY_CHASSIS',
|
[InquiryType.POLICY_BY_CHASSIS]: 'POLICY_BY_CHASSIS',
|
||||||
[InquiryType.POLICY_BY_PLATE]: 'POLICY_BY_PLATE',
|
[InquiryType.POLICY_BY_PLATE]: 'POLICY_BY_PLATE',
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { ApiProperty } from '@nestjs/swagger';
|
||||||
|
import { IsNotEmpty, IsString, Length, Matches } from 'class-validator';
|
||||||
|
|
||||||
|
export class CarByMotorRequestDto {
|
||||||
|
@ApiProperty({ example: '4311402422', description: 'Owner national code (10 digits)' })
|
||||||
|
@IsString()
|
||||||
|
@Length(10, 10)
|
||||||
|
@Matches(/^\d{10}$/, { message: 'nationalCode must be exactly 10 digits' })
|
||||||
|
nationalCode!: string;
|
||||||
|
|
||||||
|
@ApiProperty({
|
||||||
|
example: '147H0403219',
|
||||||
|
description: 'Vehicle motor/engine number',
|
||||||
|
})
|
||||||
|
@IsString()
|
||||||
|
@IsNotEmpty()
|
||||||
|
motorNo!: string;
|
||||||
|
}
|
||||||
@@ -36,6 +36,7 @@ import { PolicyByNationalCodeRequestDto } from './dto/policy-by-national-code-re
|
|||||||
import { PolicyByPlateRequestDto } from './dto/policy-by-plate-request.dto';
|
import { PolicyByPlateRequestDto } from './dto/policy-by-plate-request.dto';
|
||||||
import { CarByPlateRequestDto } from './dto/car-by-plate-request.dto';
|
import { CarByPlateRequestDto } from './dto/car-by-plate-request.dto';
|
||||||
import { CarByChassisRequestDto } from './dto/car-by-chassis-request.dto';
|
import { CarByChassisRequestDto } from './dto/car-by-chassis-request.dto';
|
||||||
|
import { CarByMotorRequestDto } from './dto/car-by-motor-request.dto';
|
||||||
import { InquiryService } from './inquiry.service';
|
import { InquiryService } from './inquiry.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,6 +177,22 @@ export class InquiryController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Post('carByMotor')
|
||||||
|
@InquiryAccess(InquiryType.CAR_BY_MOTOR)
|
||||||
|
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
||||||
|
@ApiOperation({ summary: 'Car insurance inquiry by motor/engine number (provider passthrough)' })
|
||||||
|
@ApiResponse({ status: 200, type: GenericInquiryResponseDto })
|
||||||
|
async inquireCarByMotor(
|
||||||
|
@Body() payload: CarByMotorRequestDto,
|
||||||
|
@Req() req: Request & { requestId?: string; trackingCode?: string },
|
||||||
|
): Promise<BaseInquiryResponseDto<Record<string, unknown>>> {
|
||||||
|
return this.inquireGeneric(
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
|
payload as unknown as Record<string, unknown>,
|
||||||
|
req,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Post('thirdPartyCar')
|
@Post('thirdPartyCar')
|
||||||
@InquiryAccess(InquiryType.THIRD_PARTY_CAR)
|
@InquiryAccess(InquiryType.THIRD_PARTY_CAR)
|
||||||
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
@Throttle({ default: { limit: 30, ttl: 60000 } })
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { AmitisProvider } from './amitis.provider';
|
|||||||
import {
|
import {
|
||||||
CentInsurCarProviderSupport,
|
CentInsurCarProviderSupport,
|
||||||
CarChassisPayload,
|
CarChassisPayload,
|
||||||
|
CarMotorPayload,
|
||||||
CarPlatePayload,
|
CarPlatePayload,
|
||||||
} from '../shared/centinsur-car-provider.support';
|
} from '../shared/centinsur-car-provider.support';
|
||||||
import {
|
import {
|
||||||
@@ -103,6 +104,7 @@ export class ParsianProvider extends BaseProvider<LegacyInquiryPayload, LegacyIn
|
|||||||
InquiryType.SHEBA,
|
InquiryType.SHEBA,
|
||||||
InquiryType.CAR_BY_PLATE,
|
InquiryType.CAR_BY_PLATE,
|
||||||
InquiryType.CAR_BY_CHASSIS,
|
InquiryType.CAR_BY_CHASSIS,
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
InquiryType.THIRD_PARTY_CAR,
|
InquiryType.THIRD_PARTY_CAR,
|
||||||
InquiryType.POLICY_BY_CHASSIS,
|
InquiryType.POLICY_BY_CHASSIS,
|
||||||
InquiryType.POLICY_BY_PLATE,
|
InquiryType.POLICY_BY_PLATE,
|
||||||
@@ -137,6 +139,7 @@ export class ParsianProvider extends BaseProvider<LegacyInquiryPayload, LegacyIn
|
|||||||
this.hasSoapCredentials(policyByPlateConfig) ||
|
this.hasSoapCredentials(policyByPlateConfig) ||
|
||||||
this.hasSoapCredentials(policyByNationalCodeConfig) ||
|
this.hasSoapCredentials(policyByNationalCodeConfig) ||
|
||||||
this.centInsurCarSupport.hasCarPolicyConfig(this.config, InquiryType.CAR_BY_PLATE) ||
|
this.centInsurCarSupport.hasCarPolicyConfig(this.config, InquiryType.CAR_BY_PLATE) ||
|
||||||
|
this.centInsurCarSupport.hasCarPolicyConfig(this.config, InquiryType.CAR_BY_MOTOR) ||
|
||||||
this.centInsurCarSupport.hasCarPolicyConfig(this.config, InquiryType.THIRD_PARTY_CAR))
|
this.centInsurCarSupport.hasCarPolicyConfig(this.config, InquiryType.THIRD_PARTY_CAR))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -178,6 +181,16 @@ export class ParsianProvider extends BaseProvider<LegacyInquiryPayload, LegacyIn
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (inquiryType === InquiryType.CAR_BY_MOTOR) {
|
||||||
|
return this.centInsurCarSupport.inquireCarByMotor(
|
||||||
|
this.config,
|
||||||
|
payload as CarMotorPayload,
|
||||||
|
(message, code, fallback, extras) =>
|
||||||
|
this.formatProviderError(message, code, fallback, extras as never),
|
||||||
|
context.signal,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (inquiryType === InquiryType.THIRD_PARTY_CAR) {
|
if (inquiryType === InquiryType.THIRD_PARTY_CAR) {
|
||||||
// Parsian third-party plate inquiries must use the one-factor plate
|
// Parsian third-party plate inquiries must use the one-factor plate
|
||||||
// lookup. The national-code policy endpoint is not a substitute: it
|
// lookup. The national-code policy endpoint is not a substitute: it
|
||||||
|
|||||||
@@ -54,6 +54,22 @@ export class CentInsurCarPolicyClient {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async inquireByMotor(
|
||||||
|
config: ProviderEnvConfig,
|
||||||
|
inquiryType: InquiryType,
|
||||||
|
motorNo: string,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
): Promise<Record<string, string>> {
|
||||||
|
return this.callSoap(
|
||||||
|
config,
|
||||||
|
inquiryType,
|
||||||
|
InquiryType.POLICY_BY_PLATE,
|
||||||
|
'CIIWSPolicyMotor',
|
||||||
|
{ MotorNo: motorNo },
|
||||||
|
signal,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async inquireByNationalCode(
|
async inquireByNationalCode(
|
||||||
config: ProviderEnvConfig,
|
config: ProviderEnvConfig,
|
||||||
inquiryType: InquiryType,
|
inquiryType: InquiryType,
|
||||||
@@ -145,6 +161,7 @@ export class CentInsurCarPolicyClient {
|
|||||||
InquiryType.POLICY_BY_NATIONAL_CODE,
|
InquiryType.POLICY_BY_NATIONAL_CODE,
|
||||||
InquiryType.POLICY_BY_CHASSIS,
|
InquiryType.POLICY_BY_CHASSIS,
|
||||||
InquiryType.CAR_BY_PLATE,
|
InquiryType.CAR_BY_PLATE,
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
InquiryType.THIRD_PARTY_CAR,
|
InquiryType.THIRD_PARTY_CAR,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,11 @@ export interface CarChassisPayload extends LegacyInquiryPayload {
|
|||||||
chassisNo?: string;
|
chassisNo?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface CarMotorPayload extends LegacyInquiryPayload {
|
||||||
|
nationalCode?: string;
|
||||||
|
motorNo?: string;
|
||||||
|
}
|
||||||
|
|
||||||
type ErrorFormatter = (
|
type ErrorFormatter = (
|
||||||
providerMessage?: string,
|
providerMessage?: string,
|
||||||
providerCode?: string,
|
providerCode?: string,
|
||||||
@@ -88,6 +93,32 @@ export class CentInsurCarProviderSupport {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async inquireCarByMotor(
|
||||||
|
config: ProviderEnvConfig,
|
||||||
|
payload: CarMotorPayload,
|
||||||
|
formatError: ErrorFormatter,
|
||||||
|
signal?: AbortSignal,
|
||||||
|
): Promise<{ raw: unknown }> {
|
||||||
|
const nationalCode = this.getRequiredString(payload.nationalCode, 'nationalCode', formatError);
|
||||||
|
const motorNo = this.getRequiredString(payload.motorNo, 'motorNo', formatError);
|
||||||
|
const policy = await this.carPolicyClient.inquireByMotor(
|
||||||
|
config,
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
|
motorNo,
|
||||||
|
signal,
|
||||||
|
);
|
||||||
|
|
||||||
|
assertCarPolicyOwnedBy(nationalCode, policy, formatError);
|
||||||
|
|
||||||
|
return {
|
||||||
|
raw: {
|
||||||
|
nationalCode,
|
||||||
|
motorNo,
|
||||||
|
...policy,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async inquireThirdPartyCar(
|
async inquireThirdPartyCar(
|
||||||
config: ProviderEnvConfig,
|
config: ProviderEnvConfig,
|
||||||
payload: CarPlatePayload,
|
payload: CarPlatePayload,
|
||||||
|
|||||||
+249
-21
@@ -10,6 +10,11 @@
|
|||||||
batchRunning: false,
|
batchRunning: false,
|
||||||
batchStopRequested: false,
|
batchStopRequested: false,
|
||||||
batchResults: [],
|
batchResults: [],
|
||||||
|
batchEndpoints: [],
|
||||||
|
batchRecords: [],
|
||||||
|
batchRowEntries: new Map(),
|
||||||
|
batchCompleted: 0,
|
||||||
|
batchTotal: 0,
|
||||||
};
|
};
|
||||||
const $ = (id) => document.getElementById(id);
|
const $ = (id) => document.getElementById(id);
|
||||||
|
|
||||||
@@ -74,6 +79,13 @@
|
|||||||
{ key: 'chassisNo', label: 'Chassis / VIN', example: 'IRFC89R2VSY976455', required: true, description: 'Vehicle chassis number or VIN' },
|
{ key: 'chassisNo', label: 'Chassis / VIN', example: 'IRFC89R2VSY976455', required: true, description: 'Vehicle chassis number or VIN' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
carByMotor: {
|
||||||
|
description: 'CarByMotorRequestDto — owner national code and motor/engine number.',
|
||||||
|
fields: [
|
||||||
|
{ key: 'nationalCode', label: 'National code', example: '4311402422', required: true, description: 'Owner national code (10 digits)', pattern: '\\d{10}' },
|
||||||
|
{ key: 'motorNo', label: 'Motor number', example: '147H0403219', required: true, description: 'Vehicle motor/engine number' },
|
||||||
|
],
|
||||||
|
},
|
||||||
thirdPartyCar: {
|
thirdPartyCar: {
|
||||||
description: 'Uses CarByPlateRequestDto for the third-party car route.',
|
description: 'Uses CarByPlateRequestDto for the third-party car route.',
|
||||||
fields: [
|
fields: [
|
||||||
@@ -438,6 +450,7 @@
|
|||||||
const raw = value && typeof value === 'object' ? value : {};
|
const raw = value && typeof value === 'object' ? value : {};
|
||||||
const source = (raw.request && typeof raw.request === 'object' ? raw.request : raw.payload && typeof raw.payload === 'object' ? raw.payload : raw);
|
const source = (raw.request && typeof raw.request === 'object' ? raw.request : raw.payload && typeof raw.payload === 'object' ? raw.payload : raw);
|
||||||
const plateObject = source.plate && typeof source.plate === 'object' ? source.plate : {};
|
const plateObject = source.plate && typeof source.plate === 'object' ? source.plate : {};
|
||||||
|
const vehicleObject = source.vehicle && typeof source.vehicle === 'object' ? source.vehicle : {};
|
||||||
const directPlate = firstValue(source, ['plate', 'Plate', 'licensePlate', 'license_plate']);
|
const directPlate = firstValue(source, ['plate', 'Plate', 'licensePlate', 'license_plate']);
|
||||||
const plateText = directPlate && typeof directPlate === 'object' ? firstValue(plateObject, ['value', 'number']) : (directPlate ?? firstValue(plateObject, ['value', 'number']));
|
const plateText = directPlate && typeof directPlate === 'object' ? firstValue(plateObject, ['value', 'number']) : (directPlate ?? firstValue(plateObject, ['value', 'number']));
|
||||||
let plk1 = firstValue(source, ['plk1', 'Plk1', 'plk01', 'platePart1', 'plate1', 'plaque_2', 'پلاک1']);
|
let plk1 = firstValue(source, ['plk1', 'Plk1', 'plk01', 'platePart1', 'plate1', 'plaque_2', 'پلاک1']);
|
||||||
@@ -451,19 +464,31 @@
|
|||||||
plk1 = plk1 ?? plateMatch[1]; plk2 = plk2 ?? plateMatch[2]; plk3 = plk3 ?? plateMatch[3]; plksrl = plksrl ?? plateMatch[4];
|
plk1 = plk1 ?? plateMatch[1]; plk2 = plk2 ?? plateMatch[2]; plk3 = plk3 ?? plateMatch[3]; plksrl = plksrl ?? plateMatch[4];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const payload = {
|
const nationalCode = String(firstValue(source, ['nationalCode', 'NationalCode', 'national_code', 'nationalId', 'NationalId', 'NIN', 'nin', 'کدملی', 'کد ملی']) ?? '').trim();
|
||||||
nationalCode: String(firstValue(source, ['nationalCode', 'NationalCode', 'national_code', 'nationalId', 'NationalId', 'NIN', 'nin', 'کدملی', 'کد ملی']) ?? '').trim(),
|
const chassisNo = String(firstValue(source, ['chassisNo', 'ChassisNo', 'chassis_no', 'chassis', 'vin', 'VIN', 'vinNumber', 'vin_number', 'شماره شاسی', 'شاسی']) ?? firstValue(vehicleObject, ['chassisNo', 'ChassisNo', 'chassis', 'vin', 'VIN']) ?? '').trim();
|
||||||
|
const motorNo = String(firstValue(source, ['motorNo', 'MotorNo', 'motor_no', 'motorNumber', 'motor_number', 'engineNo', 'EngineNo', 'engineNumber', 'engine_number', 'شماره موتور', 'موتور']) ?? firstValue(vehicleObject, ['motorNo', 'MotorNo', 'motorNumber', 'engineNo', 'EngineNo', 'engineNumber']) ?? '').trim();
|
||||||
|
const platePayload = {
|
||||||
|
nationalCode,
|
||||||
plk1: String(plk1 ?? firstValue(plateObject, ['plk1', 'Plk1', 'part1']) ?? '').trim(),
|
plk1: String(plk1 ?? firstValue(plateObject, ['plk1', 'Plk1', 'part1']) ?? '').trim(),
|
||||||
plk2: String(plk2 ?? firstValue(plateObject, ['plk2', 'Plk2', 'letter']) ?? '').trim(),
|
plk2: String(plk2 ?? firstValue(plateObject, ['plk2', 'Plk2', 'letter']) ?? '').trim(),
|
||||||
plk3: String(plk3 ?? firstValue(plateObject, ['plk3', 'Plk3', 'part3']) ?? '').trim(),
|
plk3: String(plk3 ?? firstValue(plateObject, ['plk3', 'Plk3', 'part3']) ?? '').trim(),
|
||||||
plksrl: String(plksrl ?? firstValue(plateObject, ['plksrl', 'PlkSrl', 'serial']) ?? '').trim(),
|
plksrl: String(plksrl ?? firstValue(plateObject, ['plksrl', 'PlkSrl', 'serial']) ?? '').trim(),
|
||||||
};
|
};
|
||||||
const missing = Object.entries(payload).filter(([, item]) => !item).map(([key]) => key);
|
const chassisPayload = { nationalCode, chassisNo };
|
||||||
|
const motorPayload = { nationalCode, motorNo };
|
||||||
|
const missingFor = (payload) => Object.entries(payload).filter(([, item]) => !item).map(([key]) => key);
|
||||||
|
const plateMissing = missingFor(platePayload);
|
||||||
|
const chassisMissing = missingFor(chassisPayload);
|
||||||
|
const motorMissing = missingFor(motorPayload);
|
||||||
return {
|
return {
|
||||||
index: index + 1,
|
index: index + 1,
|
||||||
raw,
|
raw,
|
||||||
payload,
|
payloads: { carByPlate: platePayload, carByChassis: chassisPayload, carByMotor: motorPayload },
|
||||||
parseError: missing.length > 0 ? `Missing field(s): ${missing.join(', ')}` : undefined,
|
parseErrors: {
|
||||||
|
carByPlate: plateMissing.length > 0 ? `Missing plate field(s): ${plateMissing.join(', ')}` : undefined,
|
||||||
|
carByChassis: chassisMissing.length > 0 ? `Missing chassis field(s): ${chassisMissing.join(', ')}` : undefined,
|
||||||
|
carByMotor: motorMissing.length > 0 ? `Missing motor field(s): ${motorMissing.join(', ')}` : undefined,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
function parseBatchInput(text) {
|
function parseBatchInput(text) {
|
||||||
@@ -479,23 +504,152 @@
|
|||||||
if (!records.length) throw new Error('Batch input contains no records.');
|
if (!records.length) throw new Error('Batch input contains no records.');
|
||||||
return records.map(normalizeBatchRecord);
|
return records.map(normalizeBatchRecord);
|
||||||
}
|
}
|
||||||
|
const NO_MATCH_CODES = ['NO_MATCH', 'INQUIRY_NO_MATCH', 'CAR_POLICY_NOT_FOUND', 'RECORD_NOT_FOUND', 'REAL_ESTATE_NOT_FOUND', 'SHAHKAR_NO_MATCH', 'SHEBA_MISMATCH'];
|
||||||
|
|
||||||
function selectedBatchEndpoints() {
|
function selectedBatchEndpoints() {
|
||||||
return Array.from(document.querySelectorAll('input[name="batchEndpoint"]:checked')).map((input) => input.value);
|
const mode = $('batchInquiryMode').value;
|
||||||
|
if (mode === 'both') return ['carByPlate', 'carByChassis'];
|
||||||
|
if (mode === 'all') return ['carByPlate', 'carByChassis', 'carByMotor'];
|
||||||
|
return [mode];
|
||||||
|
}
|
||||||
|
function batchEndpointLabel(endpoint) {
|
||||||
|
if (endpoint === 'carByPlate') return 'Plate';
|
||||||
|
if (endpoint === 'carByChassis') return 'Chassis / VIN';
|
||||||
|
if (endpoint === 'carByMotor') return 'Motor';
|
||||||
|
return endpoint || '—';
|
||||||
|
}
|
||||||
|
function isNoMatchStatus(status) {
|
||||||
|
return NO_MATCH_CODES.includes(status);
|
||||||
|
}
|
||||||
|
function latestBatchResult(recordIndex, endpoint) {
|
||||||
|
for (let index = state.batchResults.length - 1; index >= 0; index -= 1) {
|
||||||
|
const result = state.batchResults[index];
|
||||||
|
if (result.index === recordIndex && result.endpoint === endpoint) return result;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
function getPlateVinCoverage(recordIndex) {
|
||||||
|
const plate = latestBatchResult(recordIndex, 'carByPlate');
|
||||||
|
const chassis = latestBatchResult(recordIndex, 'carByChassis');
|
||||||
|
const motor = latestBatchResult(recordIndex, 'carByMotor');
|
||||||
|
let status = 'pending';
|
||||||
|
if (plate?.status === 'SUCCESS' || chassis?.status === 'SUCCESS') status = 'answered';
|
||||||
|
else if (plate && chassis && isNoMatchStatus(plate.status) && isNoMatchStatus(chassis.status)) status = 'unanswered';
|
||||||
|
else if (plate && chassis) status = 'inconclusive';
|
||||||
|
return { status, plate, chassis, motor, motorRecovered: status === 'unanswered' && motor?.status === 'SUCCESS' };
|
||||||
|
}
|
||||||
|
function activeBatchEndpoints() {
|
||||||
|
return state.batchEndpoints.length ? state.batchEndpoints : selectedBatchEndpoints();
|
||||||
|
}
|
||||||
|
function hasPlateVinCoverageMode() {
|
||||||
|
const selected = activeBatchEndpoints();
|
||||||
|
return selected.includes('carByPlate') && selected.includes('carByChassis');
|
||||||
|
}
|
||||||
|
function coverageBadge(text, className) {
|
||||||
|
const badge = document.createElement('span');
|
||||||
|
badge.className = `coverage-badge ${className || ''}`.trim();
|
||||||
|
badge.textContent = text;
|
||||||
|
return badge;
|
||||||
|
}
|
||||||
|
function applyCoverageFilter() {
|
||||||
|
const unansweredOnly = $('batchUnansweredOnly').checked;
|
||||||
|
state.batchRowEntries.forEach((entries, recordIndex) => {
|
||||||
|
const coverage = getPlateVinCoverage(recordIndex);
|
||||||
|
const hidden = unansweredOnly && coverage.status !== 'unanswered';
|
||||||
|
entries.forEach(({ row, detailRow }) => {
|
||||||
|
row.classList.toggle('coverage-filtered', hidden);
|
||||||
|
detailRow.classList.toggle('coverage-filtered', hidden);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function renderRecordCoverage(recordIndex) {
|
||||||
|
const entries = state.batchRowEntries.get(recordIndex) || [];
|
||||||
|
if (!entries.length || !hasPlateVinCoverageMode()) return;
|
||||||
|
const coverage = getPlateVinCoverage(recordIndex);
|
||||||
|
const record = state.batchRecords.find((item) => item.index === recordIndex);
|
||||||
|
const styleClass = coverage.motorRecovered ? 'record-motor-recovered' : `record-${coverage.status}`;
|
||||||
|
|
||||||
|
entries.forEach(({ row, detailRow, actionCell, result }) => {
|
||||||
|
row.classList.remove('record-pending', 'record-answered', 'record-unanswered', 'record-inconclusive', 'record-motor-recovered');
|
||||||
|
detailRow.classList.remove('record-pending', 'record-answered', 'record-unanswered', 'record-inconclusive', 'record-motor-recovered');
|
||||||
|
row.classList.add(styleClass);
|
||||||
|
detailRow.classList.add(styleClass);
|
||||||
|
row.dataset.coverage = coverage.status;
|
||||||
|
actionCell.replaceChildren();
|
||||||
|
|
||||||
|
if (result.endpoint === 'carByMotor') {
|
||||||
|
actionCell.append(coverage.motorRecovered
|
||||||
|
? coverageBadge('Recovered by motor', 'coverage-recovered')
|
||||||
|
: coverageBadge(result.status === 'SUCCESS' ? 'Motor found' : isNoMatchStatus(result.status) ? 'Motor no-match' : 'Motor inconclusive', result.status === 'SUCCESS' ? 'coverage-good' : 'coverage-bad'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const target = entries.find((entry) => entry.result.endpoint === 'carByChassis')
|
||||||
|
|| entries.find((entry) => entry.result.endpoint === 'carByPlate');
|
||||||
|
if (!target) return;
|
||||||
|
|
||||||
|
if (coverage.status === 'answered') {
|
||||||
|
const source = coverage.plate?.status === 'SUCCESS' && coverage.chassis?.status === 'SUCCESS'
|
||||||
|
? 'Plate + VIN'
|
||||||
|
: coverage.plate?.status === 'SUCCESS' ? 'Plate' : 'VIN';
|
||||||
|
target.actionCell.append(coverageBadge(`Answered by ${source}`, 'coverage-good'));
|
||||||
|
} else if (coverage.status === 'unanswered') {
|
||||||
|
target.actionCell.append(coverageBadge('No plate/VIN answer', 'coverage-bad'));
|
||||||
|
if (coverage.motor) {
|
||||||
|
target.actionCell.append(coverage.motorRecovered
|
||||||
|
? coverageBadge('Motor found', 'coverage-recovered')
|
||||||
|
: coverageBadge(isNoMatchStatus(coverage.motor.status) ? 'Motor no-match' : 'Motor inconclusive', 'coverage-bad'));
|
||||||
|
} else if (activeBatchEndpoints().includes('carByMotor')) {
|
||||||
|
target.actionCell.append(coverageBadge('Motor pending', 'coverage-pending'));
|
||||||
|
} else if (record?.parseErrors.carByMotor) {
|
||||||
|
target.actionCell.append(coverageBadge('Motor number unavailable', 'coverage-pending'));
|
||||||
|
} else {
|
||||||
|
const button = document.createElement('button');
|
||||||
|
button.type = 'button';
|
||||||
|
button.className = 'motor-follow-up';
|
||||||
|
button.textContent = 'Test motor';
|
||||||
|
button.addEventListener('click', (event) => {
|
||||||
|
event.stopPropagation();
|
||||||
|
runMotorFollowUp(recordIndex, button);
|
||||||
|
});
|
||||||
|
target.actionCell.append(button);
|
||||||
|
}
|
||||||
|
} else if (coverage.status === 'inconclusive') {
|
||||||
|
target.actionCell.append(coverageBadge('Plate/VIN inconclusive', 'coverage-pending'));
|
||||||
|
} else {
|
||||||
|
target.actionCell.append(coverageBadge('Waiting for both', 'coverage-pending'));
|
||||||
|
}
|
||||||
|
|
||||||
|
applyCoverageFilter();
|
||||||
}
|
}
|
||||||
function addBatchResult(result) {
|
function addBatchResult(result) {
|
||||||
state.batchResults.push(result);
|
state.batchResults.push(result);
|
||||||
const row = document.createElement('tr');
|
const row = document.createElement('tr');
|
||||||
row.className = 'data-row'; row.tabIndex = 0; row.setAttribute('aria-expanded', 'false');
|
row.className = 'data-row'; row.tabIndex = 0; row.setAttribute('aria-expanded', 'false');
|
||||||
const inputLabel = result.payload ? `${result.payload.nationalCode} / ${result.payload.plk1}${result.payload.plk2}${result.payload.plk3}${result.payload.plksrl}` : '—';
|
row.dataset.recordIndex = String(result.index);
|
||||||
const values = [result.index, inputLabel, result.endpoint || '—', result.status, result.trackingCode || '—', result.message || '—'];
|
const vehicleIdentity = result.endpoint === 'carByChassis'
|
||||||
|
? result.payload?.chassisNo
|
||||||
|
: result.endpoint === 'carByMotor'
|
||||||
|
? result.payload?.motorNo
|
||||||
|
: result.payload
|
||||||
|
? `${result.payload.plk1}${result.payload.plk2}${result.payload.plk3}${result.payload.plksrl}`
|
||||||
|
: '';
|
||||||
|
const carTitle = firstValue(result.inputRecord, ['car_title', 'carTitle', 'title', 'vehicleTitle']);
|
||||||
|
const identityLabel = result.payload ? `${result.payload.nationalCode} / ${vehicleIdentity || '—'}` : '—';
|
||||||
|
const inputLabel = carTitle ? `${carTitle} · ${identityLabel}` : identityLabel;
|
||||||
|
const endpointLabel = batchEndpointLabel(result.endpoint);
|
||||||
|
const values = [result.index, inputLabel, endpointLabel, result.status, result.trackingCode || '—', result.message || '—'];
|
||||||
values.forEach((value, index) => {
|
values.forEach((value, index) => {
|
||||||
const cell = document.createElement('td');
|
const cell = document.createElement('td');
|
||||||
if (index === 0) { const toggle = document.createElement('span'); toggle.className = 'row-toggle'; toggle.textContent = '▶'; toggle.setAttribute('aria-hidden', 'true'); cell.append(toggle); }
|
if (index === 0) { const toggle = document.createElement('span'); toggle.className = 'row-toggle'; toggle.textContent = '▶'; toggle.setAttribute('aria-hidden', 'true'); cell.append(toggle); }
|
||||||
cell.append(document.createTextNode(value));
|
cell.append(document.createTextNode(value));
|
||||||
if (index === 3) { const noMatch = ['NO_MATCH', 'INQUIRY_NO_MATCH', 'CAR_POLICY_NOT_FOUND', 'RECORD_NOT_FOUND', 'REAL_ESTATE_NOT_FOUND', 'SHAHKAR_NO_MATCH', 'SHEBA_MISMATCH'].includes(result.status); cell.className = result.status === 'SUCCESS' ? 'status-success' : (noMatch ? 'status-neutral' : 'status-failure'); }
|
if (index === 3) cell.className = result.status === 'SUCCESS' ? 'status-success' : (isNoMatchStatus(result.status) ? 'status-neutral' : 'status-failure');
|
||||||
row.appendChild(cell);
|
row.appendChild(cell);
|
||||||
});
|
});
|
||||||
const detailRow = createDetailRow(6, result);
|
const actionCell = document.createElement('td');
|
||||||
|
actionCell.className = 'coverage-action';
|
||||||
|
row.appendChild(actionCell);
|
||||||
|
const detailRow = createDetailRow(7, result);
|
||||||
bindDetailToggle(row, detailRow, () => {
|
bindDetailToggle(row, detailRow, () => {
|
||||||
if (!result.trackingCode) return;
|
if (!result.trackingCode) return;
|
||||||
request(`/inquiry-logs?trackingCode=${encodeURIComponent(result.trackingCode)}&limit=1&page=1`)
|
request(`/inquiry-logs?trackingCode=${encodeURIComponent(result.trackingCode)}&limit=1&page=1`)
|
||||||
@@ -507,11 +661,78 @@
|
|||||||
})
|
})
|
||||||
.catch(() => undefined);
|
.catch(() => undefined);
|
||||||
});
|
});
|
||||||
|
if (!state.batchRowEntries.has(result.index)) state.batchRowEntries.set(result.index, []);
|
||||||
|
state.batchRowEntries.get(result.index).push({ row, detailRow, actionCell, result });
|
||||||
$('batchResultsBody').append(row, detailRow);
|
$('batchResultsBody').append(row, detailRow);
|
||||||
|
renderRecordCoverage(result.index);
|
||||||
}
|
}
|
||||||
function updateBatchSummary(completed, total) {
|
function updateBatchSummary(completed, total) {
|
||||||
$('batchProgress').value = total ? completed / total : 0;
|
state.batchCompleted = completed;
|
||||||
const success = state.batchResults.filter((item) => item.status === 'SUCCESS').length; const noMatch = state.batchResults.filter((item) => ['NO_MATCH', 'INQUIRY_NO_MATCH', 'CAR_POLICY_NOT_FOUND', 'RECORD_NOT_FOUND', 'REAL_ESTATE_NOT_FOUND', 'SHAHKAR_NO_MATCH', 'SHEBA_MISMATCH'].includes(item.status)).length; const operational = completed - success - noMatch; $('batchSummary').textContent = `${completed} / ${total} completed · ${success} success · ${noMatch} no-match · ${operational} operational failure${operational === 1 ? '' : 's'}`;
|
state.batchTotal = total;
|
||||||
|
$('batchProgress').value = total ? Math.min(1, completed / total) : 0;
|
||||||
|
const counts = (items) => {
|
||||||
|
const success = items.filter((item) => item.status === 'SUCCESS').length;
|
||||||
|
const noMatch = items.filter((item) => isNoMatchStatus(item.status)).length;
|
||||||
|
const invalid = items.filter((item) => item.status === 'INVALID_INPUT').length;
|
||||||
|
return { success, noMatch, invalid, operational: items.length - success - noMatch - invalid };
|
||||||
|
};
|
||||||
|
const selected = activeBatchEndpoints();
|
||||||
|
const selectedResults = state.batchResults.filter((item) => selected.includes(item.endpoint));
|
||||||
|
const overall = counts(selectedResults);
|
||||||
|
const methodBreakdown = selected.length > 1
|
||||||
|
? selected.map((endpoint) => {
|
||||||
|
const label = batchEndpointLabel(endpoint);
|
||||||
|
const method = counts(selectedResults.filter((item) => item.endpoint === endpoint));
|
||||||
|
return `${label}: ${method.success} success, ${method.noMatch} no-match, ${method.operational} failed${method.invalid ? `, ${method.invalid} invalid` : ''}`;
|
||||||
|
}).join(' · ')
|
||||||
|
: '';
|
||||||
|
|
||||||
|
if (hasPlateVinCoverageMode()) {
|
||||||
|
const coverage = state.batchRecords.map((record) => getPlateVinCoverage(record.index));
|
||||||
|
const answered = coverage.filter((item) => item.status === 'answered').length;
|
||||||
|
const unanswered = coverage.filter((item) => item.status === 'unanswered').length;
|
||||||
|
const inconclusive = coverage.filter((item) => item.status === 'inconclusive').length;
|
||||||
|
const pending = coverage.filter((item) => item.status === 'pending').length;
|
||||||
|
const motorRecovered = coverage.filter((item) => item.motorRecovered).length;
|
||||||
|
const records = state.batchRecords.length;
|
||||||
|
const percent = (value) => records ? `${((value / records) * 100).toFixed(1)}%` : '0.0%';
|
||||||
|
$('batchCoverage').classList.remove('hidden');
|
||||||
|
$('batchCoverageFilter').classList.remove('hidden');
|
||||||
|
$('coverageAnswered').textContent = `${answered} / ${records}`;
|
||||||
|
$('coverageAnsweredRate').textContent = percent(answered);
|
||||||
|
$('coverageUnanswered').textContent = `${unanswered} / ${records}`;
|
||||||
|
$('coverageUnansweredRate').textContent = percent(unanswered);
|
||||||
|
$('coverageInconclusive').textContent = String(inconclusive);
|
||||||
|
$('coverageMotorRecovered').textContent = String(motorRecovered);
|
||||||
|
$('batchSummary').textContent = `${completed} / ${total} requests completed · Plate + VIN answered ${answered}/${records} (${percent(answered)}) · no answer from either ${unanswered}/${records} (${percent(unanswered)})${inconclusive ? ` · ${inconclusive} inconclusive` : ''}${pending ? ` · ${pending} pending` : ''} · ${methodBreakdown}`;
|
||||||
|
} else {
|
||||||
|
$('batchCoverage').classList.add('hidden');
|
||||||
|
$('batchCoverageFilter').classList.add('hidden');
|
||||||
|
$('batchUnansweredOnly').checked = false;
|
||||||
|
$('batchSummary').textContent = `${completed} / ${total} completed · ${overall.success} success · ${overall.noMatch} no-match · ${overall.operational} operational failure${overall.operational === 1 ? '' : 's'}${overall.invalid ? ` · ${overall.invalid} invalid input${overall.invalid === 1 ? '' : 's'}` : ''}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async function runMotorFollowUp(recordIndex, button) {
|
||||||
|
const record = state.batchRecords.find((item) => item.index === recordIndex);
|
||||||
|
if (!record || latestBatchResult(recordIndex, 'carByMotor')) return;
|
||||||
|
button.disabled = true;
|
||||||
|
button.textContent = 'Testing…';
|
||||||
|
const payload = record.payloads.carByMotor;
|
||||||
|
let result;
|
||||||
|
try {
|
||||||
|
const body = await request('/inquiry/carByMotor', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Idempotency-Key': `batch-followup-${Date.now()}-${record.index}-carByMotor` },
|
||||||
|
body: JSON.stringify(payload),
|
||||||
|
});
|
||||||
|
result = { index: record.index, payload, endpoint: 'carByMotor', status: body.success ? 'SUCCESS' : (body.error?.code || 'NO_MATCH'), trackingCode: body.trackingCode, message: body.success ? (body.message || 'Completed') : (body.error?.messageFa || body.error?.message || 'Inquiry returned no result'), response: body };
|
||||||
|
} catch (error) {
|
||||||
|
result = { index: record.index, payload, endpoint: 'carByMotor', status: 'REQUEST_ERROR', message: error.message, response: error.body };
|
||||||
|
}
|
||||||
|
result.inputRecord = record.raw;
|
||||||
|
addBatchResult(result);
|
||||||
|
updateBatchSummary(state.batchCompleted, state.batchTotal);
|
||||||
|
await Promise.allSettled([loadMetrics(), loadLogs()]);
|
||||||
}
|
}
|
||||||
function wait(milliseconds) {
|
function wait(milliseconds) {
|
||||||
return milliseconds > 0 ? new Promise((resolve) => setTimeout(resolve, milliseconds)) : Promise.resolve();
|
return milliseconds > 0 ? new Promise((resolve) => setTimeout(resolve, milliseconds)) : Promise.resolve();
|
||||||
@@ -519,7 +740,6 @@
|
|||||||
async function runBatchTest() {
|
async function runBatchTest() {
|
||||||
if (state.batchRunning) return;
|
if (state.batchRunning) return;
|
||||||
const endpoints = selectedBatchEndpoints();
|
const endpoints = selectedBatchEndpoints();
|
||||||
if (!endpoints.length) { showError('Select at least one plate endpoint.', 'appError'); return; }
|
|
||||||
let records;
|
let records;
|
||||||
try { records = parseBatchInput($('batchPayload').value.trim()); } catch (error) { showError(error.message, 'appError'); return; }
|
try { records = parseBatchInput($('batchPayload').value.trim()); } catch (error) { showError(error.message, 'appError'); return; }
|
||||||
const delay = Math.min(10000, Math.max(0, Number($('batchDelay').value) || 0));
|
const delay = Math.min(10000, Math.max(0, Number($('batchDelay').value) || 0));
|
||||||
@@ -527,32 +747,39 @@
|
|||||||
if (total > 50 && !window.confirm(`Run ${total} requests (${records.length} record(s) × ${endpoints.length} endpoint(s))?`)) return;
|
if (total > 50 && !window.confirm(`Run ${total} requests (${records.length} record(s) × ${endpoints.length} endpoint(s))?`)) return;
|
||||||
let completed = 0;
|
let completed = 0;
|
||||||
state.batchRunning = true; state.batchStopRequested = false; state.batchResults = [];
|
state.batchRunning = true; state.batchStopRequested = false; state.batchResults = [];
|
||||||
$('batchResultsBody').replaceChildren(); $('batchOutput').textContent = 'Running batch… click any completed row to inspect its response.'; $('batchProgress').classList.remove('hidden'); $('runBatchButton').disabled = true; $('stopBatchButton').classList.remove('hidden');
|
state.batchEndpoints = endpoints; state.batchRecords = records; state.batchRowEntries = new Map(); state.batchCompleted = 0; state.batchTotal = total;
|
||||||
|
$('batchUnansweredOnly').checked = false;
|
||||||
|
$('batchResultsBody').replaceChildren(); $('batchOutput').textContent = 'Running batch… plate + VIN coverage updates as each pair completes.'; $('batchProgress').classList.remove('hidden'); $('runBatchButton').disabled = true; $('batchInquiryMode').disabled = true; $('stopBatchButton').classList.remove('hidden');
|
||||||
updateBatchSummary(0, total);
|
updateBatchSummary(0, total);
|
||||||
try {
|
try {
|
||||||
for (const record of records) {
|
for (const record of records) {
|
||||||
for (const endpoint of endpoints) {
|
for (const endpoint of endpoints) {
|
||||||
if (state.batchStopRequested) break;
|
if (state.batchStopRequested) break;
|
||||||
let result;
|
let result;
|
||||||
if (record.parseError) {
|
const payload = record.payloads[endpoint];
|
||||||
result = { index: record.index, payload: record.payload, endpoint, status: 'INVALID_INPUT', message: record.parseError };
|
const parseError = record.parseErrors[endpoint];
|
||||||
|
if (parseError) {
|
||||||
|
result = { index: record.index, payload, endpoint, status: 'INVALID_INPUT', message: parseError };
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
const body = await request('/inquiry/' + endpoint, { method: 'POST', headers: { 'Idempotency-Key': `batch-${Date.now()}-${record.index}-${endpoint}` }, body: JSON.stringify(record.payload) });
|
const body = await request('/inquiry/' + endpoint, { method: 'POST', headers: { 'Idempotency-Key': `batch-${Date.now()}-${record.index}-${endpoint}` }, body: JSON.stringify(payload) });
|
||||||
result = { index: record.index, payload: record.payload, endpoint, status: body.success ? 'SUCCESS' : (body.error?.code || 'NO_MATCH'), trackingCode: body.trackingCode, message: body.success ? (body.message || 'Completed') : (body.error?.messageFa || body.error?.message || 'Inquiry returned no result'), response: body };
|
result = { index: record.index, payload, endpoint, status: body.success ? 'SUCCESS' : (body.error?.code || 'NO_MATCH'), trackingCode: body.trackingCode, message: body.success ? (body.message || 'Completed') : (body.error?.messageFa || body.error?.message || 'Inquiry returned no result'), response: body };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
result = { index: record.index, payload: record.payload, endpoint, status: 'REQUEST_ERROR', message: error.message, response: error.body };
|
result = { index: record.index, payload, endpoint, status: 'REQUEST_ERROR', message: error.message, response: error.body };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result.inputRecord = record.raw;
|
||||||
addBatchResult(result); completed += 1; updateBatchSummary(completed, total); await wait(delay);
|
addBatchResult(result); completed += 1; updateBatchSummary(completed, total); await wait(delay);
|
||||||
}
|
}
|
||||||
if (state.batchStopRequested) break;
|
if (state.batchStopRequested) break;
|
||||||
}
|
}
|
||||||
$('batchOutput').textContent = 'Batch finished. Click any row to inspect its full request and response.';
|
$('batchOutput').textContent = hasPlateVinCoverageMode()
|
||||||
|
? 'Batch finished. Green records were answered by plate or VIN; red records had no answer from either. Use Test motor on a red record for a targeted follow-up.'
|
||||||
|
: 'Batch finished. Click any row to inspect its full request and response.';
|
||||||
if (state.batchStopRequested) $('batchSummary').textContent += ' · stopped by user';
|
if (state.batchStopRequested) $('batchSummary').textContent += ' · stopped by user';
|
||||||
await Promise.allSettled([loadMetrics(), loadLogs()]);
|
await Promise.allSettled([loadMetrics(), loadLogs()]);
|
||||||
} finally {
|
} finally {
|
||||||
state.batchRunning = false; state.batchStopRequested = false; $('runBatchButton').disabled = false; $('stopBatchButton').disabled = false; $('stopBatchButton').classList.add('hidden');
|
state.batchRunning = false; state.batchStopRequested = false; $('runBatchButton').disabled = false; $('batchInquiryMode').disabled = false; $('stopBatchButton').disabled = false; $('stopBatchButton').classList.add('hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async function clearInquiryLogs() {
|
async function clearInquiryLogs() {
|
||||||
@@ -629,6 +856,7 @@
|
|||||||
try { $('batchPayload').value = await file.text(); $('batchOutput').textContent = `Loaded ${file.name}. Click Run batch test to begin.`; } catch (_) { showError('Unable to read the selected batch file.', 'appError'); }
|
try { $('batchPayload').value = await file.text(); $('batchOutput').textContent = `Loaded ${file.name}. Click Run batch test to begin.`; } catch (_) { showError('Unable to read the selected batch file.', 'appError'); }
|
||||||
});
|
});
|
||||||
$('runBatchButton').addEventListener('click', runBatchTest);
|
$('runBatchButton').addEventListener('click', runBatchTest);
|
||||||
|
$('batchUnansweredOnly').addEventListener('change', applyCoverageFilter);
|
||||||
$('stopBatchButton').addEventListener('click', () => { state.batchStopRequested = true; $('stopBatchButton').disabled = true; });
|
$('stopBatchButton').addEventListener('click', () => { state.batchStopRequested = true; $('stopBatchButton').disabled = true; });
|
||||||
setupCollapsiblePanels();
|
setupCollapsiblePanels();
|
||||||
$('idempotencyKey').value = newKey();
|
$('idempotencyKey').value = newKey();
|
||||||
|
|||||||
+21
-10
@@ -70,6 +70,7 @@
|
|||||||
<option value="legalPerson">Legal person</option>
|
<option value="legalPerson">Legal person</option>
|
||||||
<option value="carByPlate">Car by plate</option>
|
<option value="carByPlate">Car by plate</option>
|
||||||
<option value="carByChassis">Car by chassis</option>
|
<option value="carByChassis">Car by chassis</option>
|
||||||
|
<option value="carByMotor">Car by motor number</option>
|
||||||
<option value="thirdPartyCar">Third-party car</option>
|
<option value="thirdPartyCar">Third-party car</option>
|
||||||
<option value="policyByChassis">Policy by chassis</option>
|
<option value="policyByChassis">Policy by chassis</option>
|
||||||
<option value="policyByPlate">Policy by plate</option>
|
<option value="policyByPlate">Policy by plate</option>
|
||||||
@@ -96,28 +97,38 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="panel">
|
<section class="panel">
|
||||||
<div class="panel-heading"><div><p class="eyebrow">Batch input</p><h2>Test plate inquiries from JSON</h2></div></div>
|
<div class="panel-heading"><div><p class="eyebrow">Batch input</p><h2>Test vehicle inquiries from JSON</h2></div></div>
|
||||||
<p class="muted">Choose a JSON or TXT file, or paste a JSON array. For Parsian third-party plate inquiries, use <strong>Car by plate</strong>; the other routes remain available only for diagnostics.</p>
|
<p class="muted">Choose plate, chassis/VIN, motor number, or a combined mode. Each lookup produces an independently expandable result with separate logs, traces, and cURLs.</p>
|
||||||
<div class="batch-controls">
|
<div class="batch-controls">
|
||||||
<label>JSON/TXT file<input id="batchFile" type="file" accept=".json,.txt,application/json,text/plain" /></label>
|
<label>JSON/TXT file<input id="batchFile" type="file" accept=".json,.txt,application/json,text/plain" /></label>
|
||||||
|
<label>Inquiry mode
|
||||||
|
<select id="batchInquiryMode">
|
||||||
|
<option value="carByPlate">By plate</option>
|
||||||
|
<option value="carByChassis">By chassis / VIN</option>
|
||||||
|
<option value="carByMotor">By motor number</option>
|
||||||
|
<option value="both" selected>Plate and chassis</option>
|
||||||
|
<option value="all">Plate, chassis, and motor</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
<label>Delay between requests (ms)<input id="batchDelay" type="number" min="0" max="10000" step="100" value="0" /></label>
|
<label>Delay between requests (ms)<input id="batchDelay" type="number" min="0" max="10000" step="100" value="0" /></label>
|
||||||
</div>
|
</div>
|
||||||
<label class="wide">Input preview / paste JSON
|
<label class="wide">Input preview / paste JSON
|
||||||
<textarea id="batchPayload" rows="8" spellcheck="false" placeholder='[{"nationalCode":"4311402422","plk1":"12","plk2":"ب","plk3":"345","plksrl":"67"}]'></textarea>
|
<textarea id="batchPayload" rows="8" spellcheck="false" placeholder='[{"nationalCode":"4311402422","plk1":"12","plk2":"ب","plk3":"345","plksrl":"67","vin":"IRFC89R2VSY976455","motorNo":"147H0403219"}]'></textarea>
|
||||||
</label>
|
</label>
|
||||||
<div class="endpoint-list">
|
|
||||||
<span class="muted">Endpoints</span>
|
|
||||||
<label class="checkbox"><input type="checkbox" name="batchEndpoint" value="carByPlate" checked /> Car by plate</label>
|
|
||||||
<label class="checkbox"><input type="checkbox" name="batchEndpoint" value="thirdPartyCar" /> Third-party car (diagnostic)</label>
|
|
||||||
<label class="checkbox"><input type="checkbox" name="batchEndpoint" value="policyByPlate" /> Policy by plate (diagnostic)</label>
|
|
||||||
</div>
|
|
||||||
<div class="batch-actions">
|
<div class="batch-actions">
|
||||||
<button id="runBatchButton" class="primary" type="button">Run batch test</button>
|
<button id="runBatchButton" class="primary" type="button">Run batch test</button>
|
||||||
<button id="stopBatchButton" class="ghost hidden" type="button">Stop after current request</button>
|
<button id="stopBatchButton" class="ghost hidden" type="button">Stop after current request</button>
|
||||||
<span id="batchSummary" class="muted"></span>
|
<span id="batchSummary" class="muted"></span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="batchCoverage" class="coverage-grid hidden" aria-live="polite">
|
||||||
|
<article class="coverage-card coverage-card-good"><span>Answered by plate or VIN</span><strong id="coverageAnswered">0 / 0</strong><small id="coverageAnsweredRate">0.0%</small></article>
|
||||||
|
<article class="coverage-card coverage-card-bad"><span>No answer from either</span><strong id="coverageUnanswered">0 / 0</strong><small id="coverageUnansweredRate">0.0%</small></article>
|
||||||
|
<article class="coverage-card coverage-card-pending"><span>Inconclusive</span><strong id="coverageInconclusive">0</strong><small>failure or invalid input</small></article>
|
||||||
|
<article class="coverage-card coverage-card-recovered"><span>Recovered by motor</span><strong id="coverageMotorRecovered">0</strong><small>plate + VIN still count as no-answer</small></article>
|
||||||
|
</div>
|
||||||
|
<label id="batchCoverageFilter" class="checkbox coverage-filter hidden"><input id="batchUnansweredOnly" type="checkbox" /> Show only records with no plate or VIN answer</label>
|
||||||
<progress id="batchProgress" class="batch-progress hidden" max="1" value="0"></progress>
|
<progress id="batchProgress" class="batch-progress hidden" max="1" value="0"></progress>
|
||||||
<div class="table-wrap"><table><thead><tr><th>#</th><th>Input</th><th>Endpoint</th><th>Status</th><th>Tracking code</th><th>Message</th></tr></thead><tbody id="batchResultsBody"></tbody></table></div>
|
<div class="table-wrap"><table><thead><tr><th>#</th><th>Input</th><th>Endpoint</th><th>Status</th><th>Tracking code</th><th>Message</th><th>Coverage / follow-up</th></tr></thead><tbody id="batchResultsBody"></tbody></table></div>
|
||||||
<p id="batchOutput" class="table-hint" role="status">Click a request row to expand its full response.</p>
|
<p id="batchOutput" class="table-hint" role="status">Click a request row to expand its full response.</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
+30
-2
@@ -64,12 +64,25 @@ button:hover { filter: brightness(1.12); }
|
|||||||
.inquiry-form .wide, .inquiry-form button { grid-column: 1 / -1; }
|
.inquiry-form .wide, .inquiry-form button { grid-column: 1 / -1; }
|
||||||
.request-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
.request-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||||
.form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
|
.form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
|
||||||
.batch-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
|
.batch-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
|
||||||
.endpoint-list { margin: 16px 0; }
|
.endpoint-list { margin: 16px 0; }
|
||||||
.checkbox { display: inline-flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--text); font-weight: 600; }
|
.checkbox { display: inline-flex; grid-template-columns: auto 1fr; align-items: center; gap: 7px; color: var(--text); font-weight: 600; }
|
||||||
.checkbox input { width: auto; accent-color: var(--accent-strong); }
|
.checkbox input { width: auto; accent-color: var(--accent-strong); }
|
||||||
.batch-actions { margin: 16px 0; }
|
.batch-actions { margin: 16px 0; }
|
||||||
.batch-progress { width: 100%; height: 8px; margin: 4px 0 12px; accent-color: var(--accent-strong); }
|
.batch-progress { width: 100%; height: 8px; margin: 4px 0 12px; accent-color: var(--accent-strong); }
|
||||||
|
.coverage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
|
||||||
|
.coverage-card { padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(6, 12, 26, .38); }
|
||||||
|
.coverage-card span, .coverage-card small { display: block; color: var(--muted); font-size: 11px; }
|
||||||
|
.coverage-card strong { display: inline-block; margin: 4px 8px 2px 0; font-size: 23px; }
|
||||||
|
.coverage-card-good { border-color: rgba(101, 216, 178, .4); }
|
||||||
|
.coverage-card-good strong { color: var(--accent); }
|
||||||
|
.coverage-card-bad { border-color: rgba(255, 143, 143, .5); }
|
||||||
|
.coverage-card-bad strong { color: var(--danger); }
|
||||||
|
.coverage-card-pending { border-color: rgba(246, 200, 95, .42); }
|
||||||
|
.coverage-card-pending strong { color: #f6c85f; }
|
||||||
|
.coverage-card-recovered { border-color: rgba(129, 140, 248, .48); }
|
||||||
|
.coverage-card-recovered strong { color: #a5b4fc; }
|
||||||
|
.coverage-filter { margin: 10px 0; width: fit-content; }
|
||||||
.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; }
|
.field-hint { color: var(--muted); font-size: 11px; font-weight: 500; }
|
||||||
#rawMode { display: grid; gap: 12px; }
|
#rawMode { display: grid; gap: 12px; }
|
||||||
#rawMode button { justify-self: start; }
|
#rawMode button { justify-self: start; }
|
||||||
@@ -111,6 +124,21 @@ tbody tr.data-row:focus { outline: 2px solid var(--accent); outline-offset: -2px
|
|||||||
.status-success { color: var(--accent); }
|
.status-success { color: var(--accent); }
|
||||||
.status-neutral { color: #f6c85f; }
|
.status-neutral { color: #f6c85f; }
|
||||||
.status-failure { color: var(--danger); }
|
.status-failure { color: var(--danger); }
|
||||||
|
tbody tr.record-answered > td { background: rgba(32, 180, 134, .055); }
|
||||||
|
tbody tr.record-unanswered > td { background: rgba(255, 95, 95, .11); }
|
||||||
|
tbody tr.record-unanswered > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
|
||||||
|
tbody tr.record-inconclusive > td { background: rgba(246, 200, 95, .075); }
|
||||||
|
tbody tr.record-inconclusive > td:first-child { box-shadow: inset 3px 0 0 #f6c85f; }
|
||||||
|
tbody tr.record-motor-recovered > td { background: rgba(129, 140, 248, .11); }
|
||||||
|
tbody tr.record-motor-recovered > td:first-child { box-shadow: inset 3px 0 0 #818cf8; }
|
||||||
|
.coverage-filtered { display: none !important; }
|
||||||
|
.coverage-action { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; min-width: 178px; }
|
||||||
|
.coverage-badge { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
|
||||||
|
.coverage-good { border-color: rgba(101, 216, 178, .4); color: var(--accent); }
|
||||||
|
.coverage-bad { border-color: rgba(255, 143, 143, .5); color: var(--danger); }
|
||||||
|
.coverage-pending { border-color: rgba(246, 200, 95, .42); color: #f6c85f; }
|
||||||
|
.coverage-recovered { border-color: rgba(129, 140, 248, .48); color: #a5b4fc; }
|
||||||
|
.motor-follow-up { padding: 6px 10px; border: 1px solid rgba(129, 140, 248, .55); background: rgba(129, 140, 248, .13); color: #c7d2fe; font-size: 11px; font-weight: 800; }
|
||||||
.error { min-height: 20px; color: var(--danger); }
|
.error { min-height: 20px; color: var(--danger); }
|
||||||
.banner { margin: 0 0 16px; }
|
.banner { margin: 0 0 16px; }
|
||||||
@media (max-width: 780px) { .shell { width: min(100% - 20px, 680px); padding-top: 20px; } .grid.two, .inquiry-form, .form-fields, .batch-controls, .metric-grid { grid-template-columns: 1fr; } .inquiry-form .wide, .inquiry-form button { grid-column: auto; } .request-toolbar { align-items: flex-start; flex-direction: column; } .topbar { align-items: flex-start; flex-direction: column; } .topbar-actions, .panel-actions { width: 100%; justify-content: space-between; } .panel { padding: 16px; } }
|
@media (max-width: 780px) { .shell { width: min(100% - 20px, 680px); padding-top: 20px; } .grid.two, .inquiry-form, .form-fields, .batch-controls, .metric-grid, .coverage-grid { grid-template-columns: 1fr; } .inquiry-form .wide, .inquiry-form button { grid-column: auto; } .request-toolbar { align-items: flex-start; flex-direction: column; } .topbar { align-items: flex-start; flex-direction: column; } .topbar-actions, .panel-actions { width: 100%; justify-content: space-between; } .panel { padding: 16px; } }
|
||||||
|
|||||||
@@ -49,6 +49,13 @@ export const inquiryEndpointCases: InquiryEndpointCase[] = [
|
|||||||
validPayload: { postalCode: '1234567890' },
|
validPayload: { postalCode: '1234567890' },
|
||||||
invalidPayload: { postalCode: '123' },
|
invalidPayload: { postalCode: '123' },
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'car by motor inquiry',
|
||||||
|
inquiryType: InquiryType.CAR_BY_MOTOR,
|
||||||
|
path: '/inquiry/carByMotor',
|
||||||
|
validPayload: { nationalCode: '4311402422', motorNo: '147H0403219' },
|
||||||
|
invalidPayload: { nationalCode: 'bad', motorNo: '' },
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'policy by chassis inquiry',
|
name: 'policy by chassis inquiry',
|
||||||
inquiryType: InquiryType.POLICY_BY_CHASSIS,
|
inquiryType: InquiryType.POLICY_BY_CHASSIS,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
||||||
import { ParsianProvider } from '../../src/providers/implementations/parsian.provider';
|
import { ParsianProvider } from '../../src/providers/implementations/parsian.provider';
|
||||||
|
|
||||||
describe('Parsian third-party plate routing', () => {
|
describe('Parsian car inquiry routing', () => {
|
||||||
it('uses the one-factor car-by-plate provider path without a national-code lookup', async () => {
|
it('uses the one-factor car-by-plate provider path without a national-code lookup', async () => {
|
||||||
const inquireCarByPlate = jest.fn().mockResolvedValue({ raw: { policy: true } });
|
const inquireCarByPlate = jest.fn().mockResolvedValue({ raw: { policy: true } });
|
||||||
const inquireThirdPartyCar = jest.fn();
|
const inquireThirdPartyCar = jest.fn();
|
||||||
@@ -19,4 +19,25 @@ describe('Parsian third-party plate routing', () => {
|
|||||||
expect(inquireCarByPlate).toHaveBeenCalledTimes(1);
|
expect(inquireCarByPlate).toHaveBeenCalledTimes(1);
|
||||||
expect(inquireThirdPartyCar).not.toHaveBeenCalled();
|
expect(inquireThirdPartyCar).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('routes motor inquiries through the CentInsur motor support path', async () => {
|
||||||
|
const inquireCarByMotor = jest.fn().mockResolvedValue({ raw: { policy: true } });
|
||||||
|
const provider = Object.create(ParsianProvider.prototype) as any;
|
||||||
|
provider.config = {};
|
||||||
|
provider.centInsurCarSupport = { inquireCarByMotor };
|
||||||
|
|
||||||
|
const result = await provider.callProvider(
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
|
{ nationalCode: '1234567890', motorNo: '147H0403219' },
|
||||||
|
{ requestId: 'req-2', trackingCode: 'trk-2' },
|
||||||
|
);
|
||||||
|
|
||||||
|
expect(result).toEqual({ raw: { policy: true } });
|
||||||
|
expect(inquireCarByMotor).toHaveBeenCalledWith(
|
||||||
|
{},
|
||||||
|
{ nationalCode: '1234567890', motorNo: '147H0403219' },
|
||||||
|
expect.any(Function),
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,8 +2,48 @@ import {
|
|||||||
getCarPolicyProviderError,
|
getCarPolicyProviderError,
|
||||||
parseFirstCarPolicy,
|
parseFirstCarPolicy,
|
||||||
} from '../../src/common/helpers/soap-car-policy.helper';
|
} from '../../src/common/helpers/soap-car-policy.helper';
|
||||||
|
import { InquiryType } from '../../src/common/enums/inquiry-type.enum';
|
||||||
|
import { CentInsurCarPolicyClient } from '../../src/providers/shared/centinsur-car-policy.client';
|
||||||
|
|
||||||
describe('Parsian car-policy SOAP responses', () => {
|
describe('Parsian car-policy SOAP responses', () => {
|
||||||
|
it('maps motor inquiries to CIIWSPolicyMotor with the MotorNo SOAP field', async () => {
|
||||||
|
const client = new CentInsurCarPolicyClient();
|
||||||
|
const callSoap = jest.spyOn(client as any, 'callSoap').mockResolvedValue({ PlcNo: '123' });
|
||||||
|
const config = { enabled: true, timeout: 1000, maxRetries: 0, inquiries: {} };
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
client.inquireByMotor(config, InquiryType.CAR_BY_MOTOR, '147H0403219'),
|
||||||
|
).resolves.toEqual({ PlcNo: '123' });
|
||||||
|
|
||||||
|
expect(callSoap).toHaveBeenCalledWith(
|
||||||
|
config,
|
||||||
|
InquiryType.CAR_BY_MOTOR,
|
||||||
|
InquiryType.POLICY_BY_PLATE,
|
||||||
|
'CIIWSPolicyMotor',
|
||||||
|
{ MotorNo: '147H0403219' },
|
||||||
|
undefined,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('parses policy fields from a CIIWSPolicyMotorResult response', () => {
|
||||||
|
const xml = `
|
||||||
|
<CIIWSPolicyMotorResult>
|
||||||
|
<a:Policy>
|
||||||
|
<a:Policy>
|
||||||
|
<a:NtnlId>4311402422</a:NtnlId>
|
||||||
|
<a:MotorNo>147H0403219</a:MotorNo>
|
||||||
|
<a:PlcyNo>987654</a:PlcyNo>
|
||||||
|
</a:Policy>
|
||||||
|
</a:Policy>
|
||||||
|
</CIIWSPolicyMotorResult>`;
|
||||||
|
|
||||||
|
expect(parseFirstCarPolicy(xml)).toEqual({
|
||||||
|
NtnlId: '4311402422',
|
||||||
|
MotorNo: '147H0403219',
|
||||||
|
PlcyNo: '987654',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('extracts the Persian message from a nested KeyValue error and classifies no-policy', () => {
|
it('extracts the Persian message from a nested KeyValue error and classifies no-policy', () => {
|
||||||
const xml = `
|
const xml = `
|
||||||
<CIIWSPolicyNationalIdResult>
|
<CIIWSPolicyNationalIdResult>
|
||||||
|
|||||||
Reference in New Issue
Block a user