chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
46
packages/server/lib/plugins/sms/inforu/inforu.js
Normal file
46
packages/server/lib/plugins/sms/inforu/inforu.js
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
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}`)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
sendMessage
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue