Add InforU SMS plugin (#1695)
Co-authored-by: Bitcoin Change <admin@bitcoinchange.co.il>
This commit is contained in:
parent
2c8ab635a7
commit
fc6f86f51d
5 changed files with 108 additions and 0 deletions
|
|
@ -54,6 +54,7 @@ const ALL_ACCOUNTS = [
|
|||
{ code: 'twilio', display: 'Twilio', class: SMS },
|
||||
{ code: 'telnyx', display: 'Telnyx', class: SMS },
|
||||
{ code: 'vonage', display: 'Vonage', class: SMS },
|
||||
{ code: 'inforu', display: 'InforU', class: SMS },
|
||||
{ code: 'mailgun', display: 'Mailgun', class: EMAIL },
|
||||
{ code: 'mock-email', display: 'Mock Email', class: EMAIL, dev: true },
|
||||
{ code: 'none', display: 'None', class: ZERO_CONF, cryptos: ALL_CRYPTOS },
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ const SECRET_FIELDS = [
|
|||
'twilio.authToken',
|
||||
'telnyx.apiKey',
|
||||
'vonage.apiSecret',
|
||||
'inforu.apiKey',
|
||||
'galoy.walletId',
|
||||
'galoy.apiSecret',
|
||||
'bitfinex.secret'
|
||||
|
|
|
|||
51
lib/plugins/sms/inforu/inforu.js
Normal file
51
lib/plugins/sms/inforu/inforu.js
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue