Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(config: IConfig) {
this.client = new NotifyClient(config.apiKey);
/* istanbul ignore next */
this.templates = config.templates || {};
}
router.post('/dev-gov-notify', function (req, res) {
// using old style of url/clientid/apikey, this will be replaced in future with single constructor key arg
var notifyClient = new NotifyClient(
'https://api.notifications.service.gov.uk',
'11030d6a-c042-4857-aa68-99f0c7fa9352',
process.env.APVS_NOTIFY_API_KEY // API Key
)
var reference = req.body.reference
var personalisation = {reference: reference}
if (req.body.sendemail) {
var emailAddress = req.body.email
var emailTemplateId = '508b23b3-3f1c-45c2-bdc7-db90e3fae8b0' // comes from Notify site
notifyClient.sendEmail(emailTemplateId, emailAddress, personalisation)
} else {
var phoneNumber = req.body.phone
var textTemplateId = 'adf6c0bf-513a-4fe4-8023-0ae4ab55e1a1'
notifyClient.sendSms(textTemplateId, phoneNumber, personalisation)
}
var q = require('q'),
NotifyClient = require('notifications-node-client').NotifyClient,
notifyClient = !!process.env.NOTIFICATIONS_ENABLED && new NotifyClient(
process.env.NOTIFY_BASE_URL,
process.env.NOTIFY_SERVICE_ID,
process.env.NOTIFY_SECRET
);
module.exports = {
/**
* @param {String} templateId
* @param {String} emailAddress
* @param {Object} personalisation
*
* @returns {Promise}
*/
sendEmail: function(templateId, emailAddress, personalisation) {
var deferred = q.defer();