mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { ConfigService } from "@nestjs/config";
|
|
import axios from "axios";
|
|
|
|
import { NotificationStrategy } from "./notification.strategy";
|
|
|
|
@Injectable()
|
|
export class SmsNotificationStrategy implements NotificationStrategy {
|
|
constructor(private readonly configService: ConfigService) {}
|
|
|
|
async send(recipient: string, message: string): Promise<boolean> {
|
|
const url =
|
|
this.configService.get<string>("OZIKING_SMS_URL") ??
|
|
"https://notification-dev.license.aafda.gov.et/api/sms-services/ozeking/sms";
|
|
|
|
await axios.post(
|
|
url,
|
|
{
|
|
to: recipient,
|
|
sourceId: this.configService.get<string>("OZIKING_SOURCE_ID") ?? "EDR",
|
|
sourceName: this.configService.get<string>("OZIKING_SOURCE_NAME") ?? "EDR Freight",
|
|
appKey: this.configService.get<string>("OZIKING_APP_KEY") ?? "",
|
|
text: message,
|
|
callbackUrl: "",
|
|
},
|
|
{
|
|
headers: {
|
|
accept: "*/*",
|
|
"Content-Type": "application/json",
|
|
},
|
|
},
|
|
);
|
|
|
|
return true;
|
|
}
|
|
}
|