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.
36 lines
1017 B
36 lines
1017 B
2 months ago
|
const NotificationProvider = require("./notification-provider");
|
||
|
const axios = require("axios");
|
||
|
|
||
|
class Elks extends NotificationProvider {
|
||
|
name = "Elks";
|
||
|
|
||
|
/**
|
||
|
* @inheritdoc
|
||
|
*/
|
||
|
async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
|
||
|
const okMsg = "Sent Successfully.";
|
||
|
const url = "https://api.46elks.com/a1/sms";
|
||
|
|
||
|
try {
|
||
|
let data = new URLSearchParams();
|
||
|
data.append("from", notification.elksFromNumber);
|
||
|
data.append("to", notification.elksToNumber );
|
||
|
data.append("message", msg);
|
||
|
|
||
|
const config = {
|
||
|
headers: {
|
||
|
"Authorization": "Basic " + Buffer.from(`${notification.elksUsername}:${notification.elksAuthToken}`).toString("base64")
|
||
|
}
|
||
|
};
|
||
|
|
||
|
await axios.post(url, data, config);
|
||
|
|
||
|
return okMsg;
|
||
|
} catch (error) {
|
||
|
this.throwGeneralAxiosError(error);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = Elks;
|