import { nanoid } from 'nanoid' import { Injectable } from '@nestjs/common' import { AwsService } from '../aws/aws.service' import { ComteleService } from '../comtele/comtele.service' @Injectable() export class SMSService { constructor(private comteleService: ComteleService, private awsService: AwsService) {} async send(phoneNumber: string, message: string, controlId: string = nanoid()): Promise { if ((!phoneNumber.startsWith('+') || phoneNumber.startsWith('+55')) && this.comteleService.isEnabled) { return await this.comteleService.sendSMS({ controlId, phoneNumber, message, }) } return await this.awsService.sendSMS({ message, phoneNumber, }) } }