Untitled

 avatar
unknown
plain_text
4 months ago
1.6 kB
6
Indexable
public async createQuote(tokenDetails: TokenDetails): Promise<any> {
        const logger = this.log.child(getChildLoggerInstance(tokenDetails, 'PET_CREATE_QUOTE'));
        logger.info('Create quote started');
        logger.info('Retrieving active customer data having application status Inprogress');
        const record = await this.formDataRepository.getApplicationForCreateQuote(tokenDetails.customerId);
        if (!record) {
            logger.error('Creating quotes: Application Id is not present for pet application');
            throw new CustomError('NO_APPLICATION_ID');
        }
        const originationId = record?.originationId;
        try {
            await this.petOriginationService.createOffer(record?.originationId, tokenDetails);
            logger.info(`Offer created successfully for ${originationId}`);
            await this.formDataRepository?.updateRecord({ stage: PetFormStage.OFFER_CREATED }, originationId);
            logger.info(`Stage updated to ${PetFormStage.OFFER_CREATED} for ${originationId}`);
            return Promise.resolve({});
        } catch (error: any) {
            logger.error(`Error occured while calling create quote service and error is ${JSON.stringify(error)}`);
            await this.formDataRepository?.updateRecord({ stage: PetFormStage.OFFER_FAILED }, originationId);
            logger.info(`Stage updated to ${PetFormStage.OFFER_FAILED} for ${originationId}`);
            throw new CustomError(error?.name || 'CREATE_QUOTE_ERROR', error);
        }
    }
Editor is loading...
Leave a Comment