Add InforU SMS plugin (#1695)

Co-authored-by: Bitcoin Change <admin@bitcoinchange.co.il>
This commit is contained in:
sha-265 2024-07-09 00:17:42 +03:00 committed by GitHub
parent 2c8ab635a7
commit fc6f86f51d
5 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,51 @@
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
}