forked from Yara724/api
Compare commits
7 Commits
ec15cff557
...
793ff639ba
| Author | SHA1 | Date | |
|---|---|---|---|
| 793ff639ba | |||
| fd42adf9d6 | |||
| ac65cdb77b | |||
| 8430c68e3a | |||
| 49fe548215 | |||
| b67dd733cd | |||
| cc8a5354c7 |
@@ -274,6 +274,20 @@ curl -X GET "$FANAVARAN_BIME_URL/car/code-list/accident-culprit-type" \
|
||||
-H "ContractId: $CONTRACT_ID" \
|
||||
-H "Location: $LOCATION" \
|
||||
-H "Content-Type: application/json"
|
||||
|
||||
curl -X GET "$FANAVARAN_BIME_URL/car/base-info/vehicle-kinds" \
|
||||
-H "authenticationToken: $AUTHENTICATION_TOKEN" \
|
||||
-H "CorpId: $CORP_ID" \
|
||||
-H "ContractId: $CONTRACT_ID" \
|
||||
-H "Location: $LOCATION" \
|
||||
-H "Content-Type: application/json"
|
||||
|
||||
curl -X GET "$FANAVARAN_BIME_URL/car/vehicles/inquiry-by-vin?vin=IRNKAEK4150012345" \
|
||||
-H "authenticationToken: $AUTHENTICATION_TOKEN" \
|
||||
-H "CorpId: $CORP_ID" \
|
||||
-H "ContractId: $CONTRACT_ID" \
|
||||
-H "Location: $LOCATION" \
|
||||
-H "Content-Type: application/json"
|
||||
```
|
||||
|
||||
### 3B. Policy Inquiry By National Code
|
||||
|
||||
@@ -86,6 +86,27 @@ export const FANAVARAN_REMOTE_LOOKUPS: FanavaranRemoteLookupDefinition[] = [
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/base-info/file-types`,
|
||||
cacheFile: "file-types.json",
|
||||
},
|
||||
// NEW LOOKUPS ADDED
|
||||
{
|
||||
name: "cities",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/base-info/cities`,
|
||||
cacheFile: "cities.json",
|
||||
},
|
||||
{
|
||||
name: "dmg-case-type",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/car/code-list/dmg-case-type`,
|
||||
cacheFile: "dmg-case-type.json",
|
||||
},
|
||||
{
|
||||
name: "dmg-history-status",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/car/code-list/dmg-case-history-status`,
|
||||
cacheFile: "dmg-history-status.json",
|
||||
},
|
||||
{
|
||||
name: "provinces",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/base-info/Provinces`,
|
||||
cacheFile: "provinces.json",
|
||||
},
|
||||
];
|
||||
|
||||
export const TEJARAT_STATIC_ACCIDENT_FILES = {
|
||||
|
||||
@@ -265,6 +265,23 @@ export class FanavaranLookupService {
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
async vehicleById(
|
||||
clientKey: FanavaranClientKey,
|
||||
vehicleId: number,
|
||||
versionNo: number = 1,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/car/vehicles/${vehicleId}?versionno=${versionNo}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
async customerById(
|
||||
clientKey: FanavaranClientKey,
|
||||
customerId: number,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/customers/${customerId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
async inquiryByUniqueIdentifier(
|
||||
clientKey: FanavaranClientKey,
|
||||
params: {
|
||||
|
||||
@@ -238,6 +238,59 @@ export class LookupsController {
|
||||
return await this.lookupsService.getFileTypes();
|
||||
}
|
||||
|
||||
@Get("cities")
|
||||
@ApiOperation({
|
||||
summary: "Fanavaran cities lookup",
|
||||
description: "Returns city codes from common/base-info/cities.",
|
||||
})
|
||||
@ApiOkResponse({
|
||||
description: "Returns Fanavaran cities lookup data",
|
||||
schema: { type: "array", items: { type: "object" } },
|
||||
})
|
||||
async cities() {
|
||||
return await this.lookupsService.getCities();
|
||||
}
|
||||
|
||||
@Get("provinces")
|
||||
@ApiOperation({
|
||||
summary: "Fanavaran provinces lookup",
|
||||
description: "Returns province codes from common/base-info/provinces.",
|
||||
})
|
||||
@ApiOkResponse({
|
||||
description: "Returns Fanavaran provinces lookup data",
|
||||
schema: { type: "array", items: { type: "object" } },
|
||||
})
|
||||
async provinces() {
|
||||
return await this.lookupsService.getProvinces();
|
||||
}
|
||||
|
||||
@Get("dmg-case-type")
|
||||
@ApiOperation({
|
||||
summary: "Fanavaran damage case type lookup",
|
||||
description: "Returns damage case type codes from car/code-list/dmg-case-type.",
|
||||
})
|
||||
@ApiOkResponse({
|
||||
description: "Returns Fanavaran damage case type lookup data",
|
||||
schema: { type: "array", items: { type: "object" } },
|
||||
})
|
||||
async dmgCaseType() {
|
||||
return await this.lookupsService.getDmgCaseType();
|
||||
}
|
||||
|
||||
@Get("dmg-history-status")
|
||||
@ApiOperation({
|
||||
summary: "Fanavaran damage history status lookup",
|
||||
description:
|
||||
"Returns damage history status codes from car/code-list/dmg-case-history-status.",
|
||||
})
|
||||
@ApiOkResponse({
|
||||
description: "Returns Fanavaran damage history status lookup data",
|
||||
schema: { type: "array", items: { type: "object" } },
|
||||
})
|
||||
async dmgHistoryStatus() {
|
||||
return await this.lookupsService.getDmgHistoryStatus();
|
||||
}
|
||||
|
||||
@Get("inquiry-by-vin")
|
||||
@ApiOperation({
|
||||
summary: "Fanavaran vehicle inquiry by VIN",
|
||||
|
||||
@@ -127,6 +127,22 @@ export class LookupsService {
|
||||
return await this.getClientRemoteLookup("file-types");
|
||||
}
|
||||
|
||||
async getCities(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("cities");
|
||||
}
|
||||
|
||||
async getProvinces(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("provinces");
|
||||
}
|
||||
|
||||
async getDmgCaseType(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("dmg-case-type");
|
||||
}
|
||||
|
||||
async getDmgHistoryStatus(): Promise<any> {
|
||||
return await this.getClientRemoteLookup("dmg-history-status");
|
||||
}
|
||||
|
||||
async inquiryByVin(vin: string): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
return this.fanavaranLookupService.inquiryByVin(clientKey, vin);
|
||||
@@ -144,14 +160,70 @@ export class LookupsService {
|
||||
);
|
||||
}
|
||||
|
||||
async mapPolicyDetails(policy: any): Promise<any> {
|
||||
if (!policy || typeof policy !== "object") {
|
||||
return policy;
|
||||
}
|
||||
|
||||
const mappedPolicy = { ...policy };
|
||||
|
||||
// 1. Map PreviousInsuranceCorpId and TransferorInsuranceCorpId
|
||||
try {
|
||||
const companies = (await this.getClientRemoteLookup("insurance-corp")) as any[];
|
||||
if (Array.isArray(companies)) {
|
||||
if (typeof policy.PreviousInsuranceCorpId === "number") {
|
||||
const match = companies.find((c) => c.Id === policy.PreviousInsuranceCorpId);
|
||||
if (match) {
|
||||
mappedPolicy.PreviousInsuranceCorpName = match.Caption;
|
||||
}
|
||||
}
|
||||
if (typeof policy.TransferorInsuranceCorpId === "number") {
|
||||
const match = companies.find((c) => c.Id === policy.TransferorInsuranceCorpId);
|
||||
if (match) {
|
||||
mappedPolicy.TransferorInsuranceCorpName = match.Caption;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.warn(`Failed to map insurance-corp lookups: ${e.message}`);
|
||||
}
|
||||
|
||||
// 2. Map PolicyUsageTypeId
|
||||
try {
|
||||
const useTypes = (await this.getClientRemoteLookup("vehicle-use-types")) as any[];
|
||||
if (Array.isArray(useTypes) && typeof policy.PolicyUsageTypeId === "number") {
|
||||
const match = useTypes.find((t) => t.Id === policy.PolicyUsageTypeId);
|
||||
if (match) {
|
||||
mappedPolicy.PolicyUsageTypeName = match.Caption;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
this.logger.warn(`Failed to map vehicle-use-types lookups: ${e.message}`);
|
||||
}
|
||||
|
||||
return mappedPolicy;
|
||||
}
|
||||
|
||||
async thirdPartyPolicyById(policyId: number): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
return this.fanavaranLookupService.thirdPartyPolicyById(clientKey, policyId);
|
||||
const policy = await this.fanavaranLookupService.thirdPartyPolicyById(clientKey, policyId);
|
||||
return this.mapPolicyDetails(policy);
|
||||
}
|
||||
|
||||
async bodyPolicyById(policyId: number): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
return this.fanavaranLookupService.bodyPolicyById(clientKey, policyId);
|
||||
const policy = await this.fanavaranLookupService.bodyPolicyById(clientKey, policyId);
|
||||
return this.mapPolicyDetails(policy);
|
||||
}
|
||||
|
||||
async vehicleById(vehicleId: number, versionNo: number = 1): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
return this.fanavaranLookupService.vehicleById(clientKey, vehicleId, versionNo);
|
||||
}
|
||||
|
||||
async customerById(customerId: number): Promise<unknown> {
|
||||
const clientKey = this.activeClientKey();
|
||||
return this.fanavaranLookupService.customerById(clientKey, customerId);
|
||||
}
|
||||
|
||||
async getAccidentWay(): Promise<{ id: number; label: string }[]> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { HttpModule } from "@nestjs/axios";
|
||||
import { Module } from "@nestjs/common";
|
||||
import { ConfigModule } from "@nestjs/config";
|
||||
import { ConfigModule, ConfigService } from "@nestjs/config";
|
||||
import { createHttpModuleOptions } from "src/core/config/http-proxy.factory";
|
||||
|
||||
import { KavenegarService } from "./kavenegar.service";
|
||||
import { KavenegarSmsGateway } from "./kavenegar-sms.gateway";
|
||||
@@ -8,7 +9,14 @@ import { ParsianSmsGateway } from "./parsian-sms.gateway";
|
||||
import { SmsGatewayService } from "./sms-gateway.service";
|
||||
|
||||
@Module({
|
||||
imports: [HttpModule, ConfigModule],
|
||||
imports: [
|
||||
HttpModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: createHttpModuleOptions,
|
||||
}),
|
||||
ConfigModule,
|
||||
],
|
||||
providers: [
|
||||
KavenegarService,
|
||||
KavenegarSmsGateway,
|
||||
|
||||
@@ -6,10 +6,16 @@ import { SmsGatewayModule } from "./provider/sms-gateway.module";
|
||||
import { OtpGeneratorService } from "./otp-generator.service";
|
||||
import { SmsOrchestrationService } from "./sms-orchestration.service";
|
||||
import { HttpModule } from "@nestjs/axios";
|
||||
import { ConfigModule, ConfigService } from "@nestjs/config";
|
||||
import { createHttpModuleOptions } from "src/core/config/http-proxy.factory";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
HttpModule,
|
||||
HttpModule.registerAsync({
|
||||
imports: [ConfigModule],
|
||||
inject: [ConfigService],
|
||||
useFactory: createHttpModuleOptions,
|
||||
}),
|
||||
SmsGatewayModule,
|
||||
MongooseModule.forFeature([{ name: SmsText.name, schema: SmsTextSchema }]),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user