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