lamassu-server/lib/plugins/sms/inforu/inforu.js
sha-265 fc6f86f51d Add InforU SMS plugin (#1695)
Co-authored-by: Bitcoin Change <admin@bitcoinchange.co.il>
2024-07-08 17:17:42 -04:00

51 lines
982 B
JavaScript

const axios = require('axios')
const NAME = 'InforU'
function sendMessage (account, rec) {
const username = account.username
const apiKey = account.apiKey
const to = rec.sms.toNumber || account.toNumber
const text = rec.sms.body
const from = account.fromNumber
const url = 'https://capi.inforu.co.il/api/v2/SMS/SendSms'
const config = {
auth: {
username: username,
password: apiKey
},
maxBodyLength: Infinity,
headers:{
'Content-Type': 'application/json'
}
}
const data = {
Message: text,
Recipients: [{
Phone: to
}],
Settings: {
Sender: from
}
}
axios.post(url, data, config)
.catch(err => {
// console.log(err)
throw new Error(`inforu error: ${err.message}`)
})
}
function getLookup () {
throw new Error('inforu error: lookup not supported')
}
module.exports = {
NAME,
sendMessage,
getLookup
}