Untitled
unknown
plain_text
a year ago
1.1 kB
9
Indexable
@Service()
export class QuotesHandler {
private log: LoggerInterface;
public constructor() {
this.log = new Logger(__filename);
}
public async processQuotes(quotesData: any): Promise<any> {
this.log.info(`Processing quotes ${quotesData?.type}`);
try {
switch (quotesData?.type) {
case EventsConstant.LIFE_INSURANCE_OFFERS_CREATED:
return await this.getQuoteServiceObjectFromProduct(Product.Life).processQuotesSuccess(quotesData);
default:
this.log.info(`No handler for event type: ${quotesData?.type}`);
}
} catch (error) {
this.log.error(`FAILURE_IN_PROCESSING_QUOTES: ${JSON.stringify(error)}`);
}
}
private getQuoteServiceObjectFromProduct(product: Product): CommonQuoteService {
switch (product) {
case Product.Life:
return Container.get(LifeQuoteService);
default:
throw new Error('NO_QUOTE_HANDLER_FOUND_FOR_TYPE');
}
}
}
Editor is loading...
Leave a Comment