forked from Shared/esg
feat: add car inquiries with resilience, ownership privacy, and retry visibility
Introduce plate, chassis, and third-party car endpoints, a wall-clock inquiry deadline with transport-only retries, and ownership-safe no-match errors so another person's identity never leaks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -21,6 +21,11 @@ import { ProviderName } from '../../common/enums/provider-name.enum';
|
||||
import { ProviderEnvConfig } from '../../config/configuration';
|
||||
import { ProviderExecutionContext } from '../../common/interfaces/inquiry-provider.interface';
|
||||
import { AmitisProvider } from './amitis.provider';
|
||||
import {
|
||||
CentInsurCarProviderSupport,
|
||||
CarChassisPayload,
|
||||
CarPlatePayload,
|
||||
} from '../shared/centinsur-car-provider.support';
|
||||
import {
|
||||
LegacyApiProvider,
|
||||
LegacyInquiryPayload,
|
||||
@@ -68,11 +73,18 @@ export class MoallemProvider extends LegacyApiProvider {
|
||||
InquiryType.SHAHKAR,
|
||||
InquiryType.POSTAL_CODE,
|
||||
InquiryType.REAL_ESTATE,
|
||||
InquiryType.CAR_BY_PLATE,
|
||||
InquiryType.CAR_BY_CHASSIS,
|
||||
InquiryType.THIRD_PARTY_CAR,
|
||||
];
|
||||
|
||||
private readonly moallemConfig: ProviderEnvConfig;
|
||||
|
||||
constructor(configService: ConfigService, private readonly amitisProvider: AmitisProvider) {
|
||||
constructor(
|
||||
configService: ConfigService,
|
||||
private readonly amitisProvider: AmitisProvider,
|
||||
private readonly centInsurCarSupport: CentInsurCarProviderSupport,
|
||||
) {
|
||||
const config = configService.get<ProviderEnvConfig>('moallem')!;
|
||||
super(
|
||||
config,
|
||||
@@ -103,6 +115,33 @@ export class MoallemProvider extends LegacyApiProvider {
|
||||
return this.inquireSayah(payload as SayahPayload);
|
||||
}
|
||||
|
||||
if (inquiryType === InquiryType.CAR_BY_PLATE) {
|
||||
return this.centInsurCarSupport.inquireCarByPlate(
|
||||
this.moallemConfig,
|
||||
payload as CarPlatePayload,
|
||||
(message, code, fallback, extras) =>
|
||||
this.formatProviderError(message, code, fallback, extras as never),
|
||||
);
|
||||
}
|
||||
|
||||
if (inquiryType === InquiryType.CAR_BY_CHASSIS) {
|
||||
return this.centInsurCarSupport.inquireCarByChassis(
|
||||
this.moallemConfig,
|
||||
payload as CarChassisPayload,
|
||||
(message, code, fallback, extras) =>
|
||||
this.formatProviderError(message, code, fallback, extras as never),
|
||||
);
|
||||
}
|
||||
|
||||
if (inquiryType === InquiryType.THIRD_PARTY_CAR) {
|
||||
return this.centInsurCarSupport.inquireThirdPartyCar(
|
||||
this.moallemConfig,
|
||||
payload as CarPlatePayload,
|
||||
(message, code, fallback, extras) =>
|
||||
this.formatProviderError(message, code, fallback, extras as never),
|
||||
);
|
||||
}
|
||||
|
||||
return super.callProvider(inquiryType, payload, context);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user