node-red-contrib-wazo-platform
Advanced tools
Comparing version 1.0.35 to 1.0.36
@@ -58,3 +58,3 @@ global.window = global; | ||
try { | ||
const check = false; | ||
let check = false; | ||
if (this.token) { | ||
@@ -61,0 +61,0 @@ check = await this.apiClient.auth.checkToken(this.token); |
@@ -6,3 +6,3 @@ global.window = global; | ||
function request(n) { | ||
function WazoRequest(n) { | ||
RED.nodes.createNode(this, n); | ||
@@ -13,25 +13,32 @@ this.conn = RED.nodes.getNode(n.server); | ||
var node = this; | ||
this.on('input', async (msg) => { | ||
const { | ||
version, | ||
method, | ||
endpoint, | ||
body = null, | ||
header = 'application/json', | ||
tenant = this.tenant | ||
} = msg.payload; | ||
node.on('input', async msg => { | ||
const version = msg.payload.version; | ||
const method = msg.payload.method; | ||
const endpoint = msg.payload.endpoint; | ||
const body = msg.payload.body; | ||
const header = msg.payload.header || 'application/json'; | ||
const tenant = msg.payload.tenant || this.tenant; | ||
const url = `https://${node.conn.host}:${node.conn.port}/api/${node.serviceName}/${version}/${endpoint}`; | ||
const url = `https://${this.conn.host}:${this.conn.port}/api/${this.serviceName}/${version}/${endpoint}`; | ||
node.log(`Make a ${method} request to the service ${node.serviceName} on ${url}`); | ||
node.status({fill:"blue", shape:"dot", text: `Request to ${node.serviceName}!`}); | ||
const token = await node.conn.authenticate(); | ||
const result = await apiRequest(url, method, token, body, header, tenant); | ||
msg.payload = result; | ||
node.send(msg); | ||
node.status({}); | ||
this.log(`Make a ${method} request to the service ${this.serviceName} on ${url}`); | ||
this.status({ fill: "blue", shape: "dot", text: `Request to ${this.serviceName}!` }); | ||
try { | ||
const token = await this.conn.authenticate(); | ||
const result = await apiRequest(url, method, token, body, header, tenant); | ||
msg.payload = result; | ||
this.send(msg); | ||
this.status({}); | ||
} catch (error) { | ||
this.error(`Error making API request: ${error.message}`, msg); | ||
this.status({ fill: "red", shape: "ring", text: "Error" }); | ||
} | ||
}); | ||
} | ||
RED.nodes.registerType("wazo request", request); | ||
RED.nodes.registerType("wazo request", WazoRequest); | ||
}; |
{ | ||
"name": "node-red-contrib-wazo-platform", | ||
"version": "1.0.35", | ||
"version": "1.0.36", | ||
"description": "Node Red module for the Wazo Platform API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
930490
2287