forked from Yara724/api
update the fanavaran which accepts unknown person too
This commit is contained in:
@@ -117,6 +117,36 @@ export const FANAVARAN_REMOTE_LOOKUPS: FanavaranRemoteLookupDefinition[] = [
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/car/code-list/dmg-business-line`,
|
||||
cacheFile: "dmg-business-line.json",
|
||||
},
|
||||
{
|
||||
name: "gender",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/gender`,
|
||||
cacheFile: "gender.json",
|
||||
},
|
||||
{
|
||||
name: "marital-status",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/marital-status`,
|
||||
cacheFile: "marital-status.json",
|
||||
},
|
||||
{
|
||||
name: "ans",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/ans`,
|
||||
cacheFile: "ans.json",
|
||||
},
|
||||
{
|
||||
name: "countries",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/base-info/countries`,
|
||||
cacheFile: "countries.json",
|
||||
},
|
||||
{
|
||||
name: "person-kind",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/person-kind`,
|
||||
cacheFile: "person-kind.json",
|
||||
},
|
||||
{
|
||||
name: "cii-validation-status",
|
||||
url: `${FANAVARAN_LOOKUP_BASE_URL}/common/code-list/cii-validation-status`,
|
||||
cacheFile: "cii-validation-status.json",
|
||||
},
|
||||
];
|
||||
|
||||
export const TEJARAT_STATIC_ACCIDENT_FILES = {
|
||||
|
||||
@@ -315,6 +315,63 @@ export class FanavaranLookupService {
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
async getOtherPerson(
|
||||
clientKey: FanavaranClientKey,
|
||||
personId: number,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/other-people/${personId}`;
|
||||
return this.fetchFromFanavaran(clientKey, url);
|
||||
}
|
||||
|
||||
async createOtherPerson(
|
||||
clientKey: FanavaranClientKey,
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<unknown> {
|
||||
const url = `${FANAVARAN_LOOKUP_BASE_URL}/common/other-people`;
|
||||
return this.postToFanavaran(clientKey, url, payload);
|
||||
}
|
||||
|
||||
async postToFanavaran(
|
||||
clientKey: FanavaranClientKey,
|
||||
url: string,
|
||||
payload: Record<string, unknown>,
|
||||
): Promise<unknown> {
|
||||
try {
|
||||
const headers = await this.fanavaranAuthService.getRequestHeaders(
|
||||
clientKey,
|
||||
);
|
||||
|
||||
this.logger.log(`[${clientKey}] POST Fanavaran: ${url}`);
|
||||
|
||||
const response = await firstValueFrom(
|
||||
this.httpService.post(url, payload, {
|
||||
headers: {
|
||||
...headers,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
timeout: 20000,
|
||||
}),
|
||||
);
|
||||
|
||||
this.fanavaranAuthService.clearBackoff(clientKey);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
this.fanavaranAuthService.registerFailure(clientKey, error);
|
||||
const message = isAxiosError(error)
|
||||
? error.response?.data?.Message ||
|
||||
error.response?.data?.message ||
|
||||
error.message
|
||||
: error instanceof Error
|
||||
? error.message
|
||||
: "Fanavaran POST request failed";
|
||||
|
||||
this.logger.error(
|
||||
`Fanavaran POST failed for ${clientKey} (${url}): ${message}`,
|
||||
);
|
||||
throw new BadGatewayException(String(message));
|
||||
}
|
||||
}
|
||||
|
||||
async resolveInsuranceCorpId(
|
||||
clientKey: FanavaranClientKey,
|
||||
): Promise<number | null> {
|
||||
|
||||
@@ -8,6 +8,7 @@ export enum FanavaranAuditStep {
|
||||
POLICY_INQUIRY = "POLICY_INQUIRY",
|
||||
BUILD_PAYLOAD = "BUILD_PAYLOAD",
|
||||
SUBMIT_CLAIM = "SUBMIT_CLAIM",
|
||||
CREATE_OTHER_PERSON = "CREATE_OTHER_PERSON",
|
||||
SUBMIT_DAMAGE_CASE = "SUBMIT_DAMAGE_CASE",
|
||||
SUBMIT_ATTACHMENT = "SUBMIT_ATTACHMENT",
|
||||
SUBMIT_EXPERTISE = "SUBMIT_EXPERTISE",
|
||||
|
||||
Reference in New Issue
Block a user