import { Injectable } from '@nestjs/common'; import { BaseFactory } from './base.factory'; import { IntegrationStrategy } from '../strategies/integration.strategy'; import { GupshupSmsStrategy } from '../strategies/sms/gupshup-sms.strategy'; import { TubelightSmsStrategy } from '../strategies/sms/tubelight-sms.strategy'; import { Msg91SmsStrategy } from '../strategies/sms/msg91-sms.strategy'; @Injectable() export class SmsFactory implements BaseFactory { constructor( private gupshupSmsStrategy: GupshupSmsStrategy, private tubelightSmsStrategy: TubelightSmsStrategy, private msg91SmsStrategy: Msg91SmsStrategy, ) {} createProvider(service: string, provider: string): IntegrationStrategy { const key = `${service.toLowerCase()}_${provider.toLowerCase()}`; switch (key) { case 'api_gupshup': case 'sms_gupshup': return this.gupshupSmsStrategy; case 'api_tubelight': case 'sms_tubelight': return this.tubelightSmsStrategy; case 'api_msg91': case 'sms_msg91': return this.msg91SmsStrategy; default: throw new Error( `Unsupported SMS service/provider: ${service}/${provider}`, ); } } getSupportedCombinations(): Array<{ service: string; provider: string }> { return [ { service: 'API', provider: 'gupshup' }, { service: 'API', provider: 'tubelight' }, { service: 'API', provider: 'msg91' }, ]; } validateCombination(service: string, provider: string): boolean { return this.getSupportedCombinations().some( (combo) => combo.service.toLowerCase() === service.toLowerCase() && combo.provider.toLowerCase() === provider.toLowerCase(), ); } }