forked from Yara724/api
Added external APIs inquiries
This commit is contained in:
@@ -869,7 +869,68 @@ export class RequestManagementService {
|
||||
);
|
||||
}
|
||||
|
||||
// NOTE: personal inquiry is not part of Tejarat block inquiry flow.
|
||||
// ---- External inquiry 2: personal identity check (insurer/driver nationalCode + birthDate) ----
|
||||
const personalNationalCode =
|
||||
body.nationalCodeOfInsurer || body.nationalCodeOfDriver;
|
||||
const birthDateRaw =
|
||||
body.insurerBirthday ?? body.driverBirthday ?? null;
|
||||
const birthDateDigits = String(birthDateRaw ?? "")
|
||||
.replace(/\D/g, "")
|
||||
.trim();
|
||||
const personalBirthDate = Number(birthDateDigits);
|
||||
if (!personalNationalCode || !Number.isFinite(personalBirthDate) || personalBirthDate <= 0) {
|
||||
throw new BadRequestException(
|
||||
"Valid nationalCode and birthDate are required for personal inquiry.",
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const personalInquiry = await this.sandHubService.getPersonalInquiry(
|
||||
personalNationalCode,
|
||||
personalBirthDate,
|
||||
);
|
||||
this.logger.log(
|
||||
`[SANDHUB] personal inquiry success request=${req._id} nationalCode=${personalNationalCode}: ${JSON.stringify(
|
||||
personalInquiry,
|
||||
)}`,
|
||||
);
|
||||
} catch (err: any) {
|
||||
this.logger.error(
|
||||
`[SANDHUB] personal inquiry failed request=${req._id} nationalCode=${personalNationalCode}: ${err?.message || err}`,
|
||||
);
|
||||
throw new HttpException(
|
||||
"Personal identity inquiry failed",
|
||||
HttpStatus.BAD_REQUEST,
|
||||
);
|
||||
}
|
||||
|
||||
// ---- External inquiry 3: driving license check (insurerLicense + nationalCode) ----
|
||||
// const licenseNationalCode = body.nationalCodeOfInsurer || body.nationalCodeOfDriver;
|
||||
// const licenseNumber = body.insurerLicense;
|
||||
// if (!licenseNationalCode || !licenseNumber) {
|
||||
// throw new BadRequestException(
|
||||
// "nationalCode and insurerLicense are required for driving license inquiry.",
|
||||
// );
|
||||
// }
|
||||
// try {
|
||||
// const licenseInquiry = await this.sandHubService.getDrivingLicenseInfo(
|
||||
// licenseNationalCode,
|
||||
// licenseNumber,
|
||||
// );
|
||||
// this.logger.log(
|
||||
// `[SANDHUB] license inquiry success request=${req._id} nationalCode=${licenseNationalCode}: ${JSON.stringify(
|
||||
// licenseInquiry,
|
||||
// )}`,
|
||||
// );
|
||||
// } catch (err: any) {
|
||||
// this.logger.error(
|
||||
// `[SANDHUB] license inquiry failed request=${req._id} nationalCode=${licenseNationalCode}: ${err?.message || err}`,
|
||||
// );
|
||||
// throw new HttpException(
|
||||
// "Driving license inquiry failed",
|
||||
// HttpStatus.BAD_REQUEST,
|
||||
// );
|
||||
// }
|
||||
|
||||
// Find client by company code
|
||||
const clientName = inquiryMapped?.CompanyName;
|
||||
|
||||
Reference in New Issue
Block a user