forked from Yara724/api
update the fanavaran which accepts unknown person too
This commit is contained in:
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user