2022-09-15 00:11:05 -07:00
|
|
|
const NotificationProvider = require("./notification-provider");
|
|
|
|
const axios = require("axios");
|
|
|
|
|
|
|
|
class SMSManager extends NotificationProvider {
|
|
|
|
name = "SMSManager";
|
|
|
|
|
2023-08-11 00:46:41 -07:00
|
|
|
/**
|
|
|
|
* @inheritdoc
|
|
|
|
*/
|
2022-09-15 00:11:05 -07:00
|
|
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
2024-03-14 06:21:15 -07:00
|
|
|
const okMsg = "Sent Successfully.";
|
|
|
|
const url = "https://http-api.smsmanager.cz/Send";
|
|
|
|
|
2022-09-15 00:11:05 -07:00
|
|
|
try {
|
|
|
|
let data = {
|
|
|
|
apikey: notification.smsmanagerApiKey,
|
|
|
|
message: msg.replace(/[^\x00-\x7F]/g, ""),
|
2024-03-14 06:21:15 -07:00
|
|
|
number: notification.numbers,
|
|
|
|
gateway: notification.messageType,
|
2022-09-15 00:11:05 -07:00
|
|
|
};
|
2024-03-14 06:21:15 -07:00
|
|
|
await axios.get(`${url}?apikey=${data.apikey}&message=${data.message}&number=${data.number}&gateway=${data.messageType}`);
|
|
|
|
return okMsg;
|
2022-09-15 00:11:05 -07:00
|
|
|
} catch (error) {
|
|
|
|
this.throwGeneralAxiosError(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = SMSManager;
|