feat: implement subscriber info retrieval
This commit is contained in:
parent
149a2f99c8
commit
a6eb4b904f
7 changed files with 110 additions and 11 deletions
|
|
@ -37,7 +37,27 @@ function sendMessage (account, rec) {
|
|||
})
|
||||
}
|
||||
|
||||
function getLookup (account, number) {
|
||||
return Promise.resolve()
|
||||
.then(() => {
|
||||
const client = twilio(account.accountSid, account.authToken)
|
||||
return client.lookups.v1.phoneNumbers(number)
|
||||
.fetch({ addOns: ['lamassu_ekata'] })
|
||||
})
|
||||
.then(info => info.addOns.results['lamassu_ekata'])
|
||||
.catch(err => {
|
||||
if (_.includes(err.code, BAD_NUMBER_CODES)) {
|
||||
const badNumberError = new Error(err.message)
|
||||
badNumberError.name = 'BadNumberError'
|
||||
throw badNumberError
|
||||
}
|
||||
|
||||
throw new Error(`Twilio error: ${err.message}`)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NAME,
|
||||
sendMessage
|
||||
sendMessage,
|
||||
getLookup
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue