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