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
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import bitstamp from './bitstamp'
|
|||
import blockcypher from './blockcypher'
|
||||
import cex from './cex'
|
||||
import galoy from './galoy'
|
||||
import inforu from './inforu'
|
||||
import infura from './infura'
|
||||
import itbit from './itbit'
|
||||
import kraken from './kraken'
|
||||
|
|
@ -21,6 +22,7 @@ export default {
|
|||
[galoy.code]: galoy,
|
||||
[bitstamp.code]: bitstamp,
|
||||
[blockcypher.code]: blockcypher,
|
||||
[inforu.code]: inforu,
|
||||
[infura.code]: infura,
|
||||
[itbit.code]: itbit,
|
||||
[kraken.code]: kraken,
|
||||
|
|
|
|||
53
new-lamassu-admin/src/pages/Services/schemas/inforu.js
Normal file
53
new-lamassu-admin/src/pages/Services/schemas/inforu.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
import * as Yup from 'yup'
|
||||
|
||||
import SecretInputFormik from 'src/components/inputs/formik/SecretInput'
|
||||
import TextInputFormik from 'src/components/inputs/formik/TextInput'
|
||||
|
||||
import { secretTest } from './helper'
|
||||
|
||||
export default {
|
||||
code: 'inforu',
|
||||
name: 'InforU',
|
||||
title: 'InforU (SMS)',
|
||||
elements: [
|
||||
{
|
||||
code: 'username',
|
||||
display: 'InforU username',
|
||||
component: TextInputFormik,
|
||||
face: true
|
||||
},
|
||||
{
|
||||
code: 'apiKey',
|
||||
display: 'API Key',
|
||||
component: SecretInputFormik
|
||||
},
|
||||
{
|
||||
code: 'fromNumber',
|
||||
display: 'InforU sender',
|
||||
component: TextInputFormik,
|
||||
face: true
|
||||
},
|
||||
{
|
||||
code: 'toNumber',
|
||||
display: 'Notifications Number (international format)',
|
||||
component: TextInputFormik,
|
||||
face: true
|
||||
}
|
||||
],
|
||||
getValidationSchema: account => {
|
||||
return Yup.object().shape({
|
||||
username: Yup.string('The InforU username must be a string')
|
||||
.max(100, 'The InforU username is too long')
|
||||
.required('The InforU username is required'),
|
||||
apiKey: Yup.string('The API key must be a string')
|
||||
.max(200, 'The API key is too long')
|
||||
.test(secretTest(account?.apiKey, 'API key')),
|
||||
fromNumber: Yup.string('The InforU sender must be a string')
|
||||
.max(11, 'The InforU sender is too long')
|
||||
.required('The InforU sender is required'),
|
||||
toNumber: Yup.string('The notifications number must be a string')
|
||||
.max(100, 'The notifications number is too long')
|
||||
.required('The notifications number is required')
|
||||
})
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue