feat: add sms preview
feat: add reset to default button feat: add attachable values feat: connect the sms receipt notice to the sms receipt request
This commit is contained in:
parent
91e209b6ab
commit
cd01d894a3
10 changed files with 186 additions and 69 deletions
35
lib/sms.js
35
lib/sms.js
|
|
@ -1,17 +1,16 @@
|
|||
|
||||
const dateFormat = require('dateformat')
|
||||
|
||||
const ph = require('./plugin-helper')
|
||||
const argv = require('minimist')(process.argv.slice(2))
|
||||
const { utils: coinUtils } = require('lamassu-coins')
|
||||
const _ = require('lodash/fp')
|
||||
|
||||
const customSms = require('./sms-notices')
|
||||
|
||||
const getDefaultMessageContent = content => ({
|
||||
smsCode: `Your cryptomat code: ${content.code}`,
|
||||
cashOutDispenseReady: `Your cash is waiting! Go to the Cryptomat and press Redeem within 24 hours. [${content.timestamp}]`
|
||||
})
|
||||
const smsNotices = require('./sms-notices')
|
||||
const { RECEIPT } = require('./constants')
|
||||
|
||||
function getSms (event, phone, content) {
|
||||
return customSms.getCustomMessage(event)
|
||||
return smsNotices.getSMSNotice(event)
|
||||
.then(msg => {
|
||||
if (!_.isNil(msg)) {
|
||||
var accMsg = msg.message
|
||||
|
|
@ -22,11 +21,6 @@ function getSms (event, phone, content) {
|
|||
body: messageContent
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
toNumber: phone,
|
||||
body: getDefaultMessageContent(content)[_.camelCase(event)]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -110,13 +104,16 @@ function formatSmsReceipt (data, options) {
|
|||
message = message.concat(`Address: ${data.address}\n`)
|
||||
}
|
||||
|
||||
const request = {
|
||||
sms: {
|
||||
toNumber: data.customerPhone,
|
||||
body: message
|
||||
}
|
||||
}
|
||||
return request
|
||||
const timestamp = dateFormat(new Date(), 'UTC:HH:MM Z')
|
||||
const postReceiptSmsPromise = getSms(RECEIPT, data.customerPhone, { timestamp })
|
||||
|
||||
return Promise.all([smsNotices.getSMSNotice(RECEIPT), postReceiptSmsPromise])
|
||||
.then(([res, postReceiptSms]) => ({
|
||||
sms: {
|
||||
toNumber: data.customerPhone,
|
||||
body: res.enabled ? message.concat('\n\n', postReceiptSms.body) : message
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue