node-red-contrib-nexmo
Advanced tools
Comparing version 3.1.5 to 3.2.0
@@ -140,3 +140,2 @@ var mustache = require("mustache"); | ||
node.on('input', function (msg) { | ||
console.log(config); | ||
var data = dataobject(this.context(), msg); | ||
@@ -143,0 +142,0 @@ this.name = mustache.render(config.name, data); |
@@ -141,4 +141,4 @@ const Nexmo = require('nexmo'); | ||
else { | ||
msg.payload=response; | ||
node.send(response) | ||
msg.payload=res; | ||
node.send(msg) | ||
} | ||
@@ -150,3 +150,3 @@ }); | ||
else { | ||
msg.payload=response; | ||
msg.payload=res; | ||
node.send(msg) | ||
@@ -179,4 +179,4 @@ } | ||
else { | ||
msg.payload=response; | ||
node.send(response) | ||
msg.payload=res; | ||
node.send(msg) | ||
} | ||
@@ -188,3 +188,3 @@ }); | ||
else { | ||
msg.payload=response; | ||
msg.payload=res; | ||
node.send(msg) | ||
@@ -215,3 +215,3 @@ } | ||
else { | ||
msg.payload=response; | ||
msg.payload=res; | ||
node.send(msg) | ||
@@ -224,5 +224,7 @@ } | ||
} | ||
function transfer(config){ | ||
RED.nodes.createNode(this, config); | ||
this.creds = RED.nodes.getNode(config.creds); | ||
this.nccotype = config.nccotype; | ||
var node = this; | ||
@@ -233,3 +235,9 @@ node.on('input', function (msg) { | ||
this.calluuid = mustache.render(config.calluuid, data); | ||
this.url = mustache.render(config.url, data); | ||
if ( this.nccotype == 'url'){ | ||
this.url = mustache.render(config.ncco, data); | ||
} else if (this.nccotype == 'json'){ | ||
this.ncco = JSON.parse(mustache.render(config.ncco, data)); | ||
} else if (this.nccotype == 'fixed'){ | ||
this.ncco = msg.ncco | ||
} | ||
const nexmo = new Nexmo({ | ||
@@ -242,3 +250,9 @@ apiKey: this.creds.credentials.apikey, | ||
); | ||
nexmo.calls.update(this.calluuid, {action: 'transfer', destination: {"type": "ncco", "url": [this.url]}}, (err, response) => { | ||
this.destination = {type:"ncco"}; | ||
if ( this.nccotype == 'url'){ | ||
this.destination.url = [this.url] | ||
} else { | ||
this.destination.ncco = this.ncco | ||
} | ||
nexmo.calls.update(this.calluuid, {action: 'transfer', destination: this.destination}, (err, response) => { | ||
if(err) { console.error(err); } | ||
@@ -330,3 +344,3 @@ else { | ||
else { | ||
msg.payload=response; | ||
msg.payload=res; | ||
node.send(msg) | ||
@@ -403,2 +417,2 @@ } | ||
} | ||
} |
{ | ||
"name": "node-red-contrib-nexmo", | ||
"version": "3.1.5", | ||
"version": "3.2.0", | ||
"description": "Node Red module for the Nexmo API", | ||
@@ -5,0 +5,0 @@ "main": "ncco.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
124205
1252