PromoSMS as Notification Provider

Add PromoSMS (Polish SMS Gateway) as new notification provider
This commit is contained in:
Lukas
2021-10-07 21:56:32 +02:00
parent ddad2dcb4a
commit 12b5489eb5
26 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
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;

View File

@@ -7,6 +7,7 @@ const LunaSea = require("./notification-providers/lunasea");
const Mattermost = require("./notification-providers/mattermost");
const Matrix = require("./notification-providers/matrix");
const Octopush = require("./notification-providers/octopush");
const PromoSMS = require("./notification-providers/promosms");
const Pushbullet = require("./notification-providers/pushbullet");
const Pushover = require("./notification-providers/pushover");
const Pushy = require("./notification-providers/pushy");
@@ -37,6 +38,7 @@ class Notification {
new Mattermost(),
new Matrix(),
new Octopush(),
new PromoSMS(),
new Pushbullet(),
new Pushover(),
new Pushy(),