summaryrefslogtreecommitdiffstats
path: root/server/notification-providers/46elks.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/notification-providers/46elks.js')
-rw-r--r--server/notification-providers/46elks.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/server/notification-providers/46elks.js b/server/notification-providers/46elks.js
new file mode 100644
index 0000000..4b15e9f
--- /dev/null
+++ b/server/notification-providers/46elks.js
@@ -0,0 +1,35 @@
+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;