Moved contents of seasoned_api up to root folder

This commit is contained in:
2022-08-19 01:03:27 +02:00
parent 0efc109992
commit 56262a45c8
134 changed files with 885 additions and 32 deletions

35
src/notifications/sms.js Normal file
View File

@@ -0,0 +1,35 @@
const request = require("request");
const configuration = require("../config/configuration").getInstance();
const sendSMS = message => {
const apiKey = configuration.get("sms", "apikey");
if (!apiKey) {
console.warning("api key for sms not set, cannot send sms.");
return null;
}
const sender = configuration.get("sms", "sender");
const recipient = configuration.get("sms", "recipient");
return new Promise((resolve, reject) => {
request.post(
{
url: `https://gatewayapi.com/rest/mtsms?token=${apiKey}`,
json: true,
body: {
sender,
message,
recipients: [{ msisdn: `47${recipient}` }]
}
},
function (err, r, body) {
console.log(err ? err : body);
console.log("sms provider response:", body);
resolve();
}
);
});
};
module.exports = { sendSMS };