Created
January 25, 2016 21:23
-
-
Save dtolb/3db7200bd955ed54705e to your computer and use it in GitHub Desktop.
SendMessage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.sendMessage = function (message) { | |
var bwClient = new bandwidth.Client( | |
config.catapult.user_id, | |
config.catapult.api_token, | |
config.catapult.api_secret | |
); | |
var buildMessage = function (message) { | |
var fromNumber = config.bandcast_number; | |
var outMessage = []; | |
for (var i = 0; i <= message.tns.length - 1; i+=1) { | |
var mess = { | |
from: fromNumber, | |
to: message.tns[i], | |
text: message.text | |
}; | |
outMessage.push(mess); | |
} | |
return outMessage; | |
}; | |
var outMessage = buildMessage(message); | |
return sendSMS(bwClient, outMessage) | |
.catch(function (e) { | |
logger.error('Error when sending broadcast'); | |
throw e; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment