forked from Shared/esg
final update on moallm client
This commit is contained in:
@@ -2,10 +2,12 @@ import { Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import { mergeOutboundAxiosConfig } from '../../common/helpers/http-client.helper';
|
||||
import { getSayahProviderError, SayahApiResponse } from '../../common/helpers/sayah-response.helper';
|
||||
import {
|
||||
getSayahProviderError,
|
||||
SayahApiResponse,
|
||||
} from '../../common/helpers/sayah-response.helper';
|
||||
describeShahkarResponse,
|
||||
getShahkarProviderError,
|
||||
normalizeShahkarFields,
|
||||
} from '../../common/helpers/shahkar-response.helper';
|
||||
import { InquiryType } from '../../common/enums/inquiry-type.enum';
|
||||
import { ProviderName } from '../../common/enums/provider-name.enum';
|
||||
import { ProviderExecutionContext } from '../../common/interfaces/inquiry-provider.interface';
|
||||
@@ -192,11 +194,22 @@ export class ParsianProvider extends BaseProvider<LegacyInquiryPayload, LegacyIn
|
||||
);
|
||||
|
||||
const body = response.data;
|
||||
const shahkarFields = normalizeShahkarFields(body as unknown as Record<string, unknown>);
|
||||
const providerError = getShahkarProviderError(shahkarFields);
|
||||
if (providerError) {
|
||||
this.nestLogger.warn(
|
||||
`SHAHKAR provider business failure | ${describeShahkarResponse(shahkarFields)}`,
|
||||
);
|
||||
throw this.formatProviderError(providerError.message, providerError.code, undefined, {
|
||||
providerTrackingCode: providerError.providerTrackingCode,
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
raw: {
|
||||
nationalCode,
|
||||
mobileNumber,
|
||||
...body,
|
||||
...shahkarFields,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user