You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
uptime-kuma/server/notification-providers/promosms.js

42 lines
1.3 KiB

const NotificationProvider = require("./notification-provider");
const axios = require("axios");
class PromoSMS extends NotificationProvider {
name = "promosms";
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
let okMsg = "Sent Successfully.";
try {
let buffer = new Buffer(notification.promosmsLogin + ":" + notification.promosmsPassword);
let promosmsAuth = buffer.toString('base64');
let config = {
headers: {
"Authorization": "Basic" + promosmsAuth,
"Content-Type": "application/x-www-form-urlencoded",
"Accept": "text/json"
}
};
let data = {
"recipients": [
{
"recipients": notification.promosmsPhoneNumber
}
],
//Lets remove non ascii char
"text": msg.replace(/[^\x00-\x7F]/g, ""),
"type": notification.promosmsSMSType,
"sender": notification.promosmsSenderName
};
await axios.post("https://promosms.com/api/rest/v3_2/sms", data, config)
return okMsg;
} catch (error) {
this.throwGeneralAxiosError(error);
}
}
}
module.exports = PromoSMS;