mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 20:40:55 +00:00
Merge branch 'freight/feature/vehicle_2' of github.com:Tria-plc/edr-platform into freight/feature/vehicle_2
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
import { Module } from "@nestjs/common";
|
import { Module } from "@nestjs/common";
|
||||||
|
import { ConfigModule } from "@nestjs/config";
|
||||||
|
|
||||||
import { NotificationsService } from "./notifications.service";
|
import { NotificationsService } from "./notifications.service";
|
||||||
import { EmailNotificationStrategy } from "./strategies/notification.email.strategy";
|
import { EmailNotificationStrategy } from "./strategies/notification.email.strategy";
|
||||||
import { SmsNotificationStrategy } from "./strategies/notification.sms.strategy";
|
import { SmsNotificationStrategy } from "./strategies/notification.sms.strategy";
|
||||||
import { HttpModule } from "@nestjs/axios";
|
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [HttpModule],
|
imports: [ConfigModule],
|
||||||
controllers: [],
|
controllers: [],
|
||||||
providers: [EmailNotificationStrategy, SmsNotificationStrategy, NotificationsService],
|
providers: [EmailNotificationStrategy, SmsNotificationStrategy, NotificationsService],
|
||||||
exports: [NotificationsService],
|
exports: [NotificationsService],
|
||||||
})
|
})
|
||||||
export class NotificationsModule { }
|
export class NotificationsModule {}
|
||||||
|
|||||||
@@ -1,28 +1,36 @@
|
|||||||
import { Injectable} from "@nestjs/common";
|
import { Injectable } from "@nestjs/common";
|
||||||
import { NotificationStrategy } from "./notification.strategy";
|
|
||||||
import { HttpService } from '@nestjs/axios';
|
|
||||||
import { ConfigService } from "@nestjs/config";
|
import { ConfigService } from "@nestjs/config";
|
||||||
import { firstValueFrom } from 'rxjs';
|
import axios from "axios";
|
||||||
|
|
||||||
|
import { NotificationStrategy } from "./notification.strategy";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SmsNotificationStrategy implements NotificationStrategy {
|
export class SmsNotificationStrategy implements NotificationStrategy {
|
||||||
constructor(private readonly httpService: HttpService, private readonly configService: ConfigService) { }
|
constructor(private readonly configService: ConfigService) {}
|
||||||
async send(recipient: string, message: string) {
|
|
||||||
const url = this.configService.get("OZIKING_SMS_URL");
|
|
||||||
const body = {
|
|
||||||
to: recipient,
|
|
||||||
sourceId: this.configService.get("OZIKING_SOURCE_ID") ?? "EDR",
|
|
||||||
sourceName: this.configService.get("OZIKING_SOURCE_NAME") ?? "EDR Freight",
|
|
||||||
appKey: this.configService.get("OZIKING_APP_KEY") ?? "",
|
|
||||||
text: message,
|
|
||||||
callbackUrl: "",
|
|
||||||
};
|
|
||||||
const response = await firstValueFrom(
|
|
||||||
this.httpService.post(url, body, {
|
|
||||||
headers: { accept: "*/*", "Content-Type": "application/json" },
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
return response.status === 201;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user