@jambonz/node-red-contrib-jambonz 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jambonz/node-red-contrib-jambonz",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "description": "Node-RED nodes for jambonz platform",
5
5
  "keywords": [
6
6
  "node-red"
@@ -6,12 +6,38 @@
6
6
  defaults: {
7
7
  name: {value: ''},
8
8
  server: {value: '', required: true, type: 'jambonz_auth'},
9
+ direction: {value: ''},
10
+ directionType:{value: 'str'},
11
+ from: {value: ''},
12
+ fromType:{value: 'str'},
13
+ to: {value: ''},
14
+ toType:{value: 'str'},
15
+ callStatus: {value: ''},
16
+ callStatusType:{value: 'str'},
9
17
  },
10
18
  inputs:1,
11
19
  outputs:1,
12
20
  icon: "font-awesome/fa-cubes",
13
21
  paletteLabel: "Get - Calls",
14
- label: function() { return this.name || 'Get Calls';}
22
+ label: function() { return this.name || 'Get Calls';},
23
+ oneditprepare: () => {
24
+ $('#node-input-direction').typedInput({
25
+ types: ['str', 'msg', 'flow', 'global'],
26
+ typeField: $('#node-input-directionType')
27
+ });
28
+ $('#node-input-from').typedInput({
29
+ types: ['str', 'msg', 'flow', 'global'],
30
+ typeField: $('#node-input-fromType')
31
+ });
32
+ $('#node-input-to').typedInput({
33
+ types: ['str', 'msg', 'flow', 'global'],
34
+ typeField: $('#node-input-toType')
35
+ });
36
+ $('#node-input-callStatus').typedInput({
37
+ types: ['str', 'msg', 'flow', 'global'],
38
+ typeField: $('#node-input-callStatusType')
39
+ });
40
+ }
15
41
  });
16
42
  </script>
17
43
 
@@ -25,6 +51,26 @@
25
51
  <label for="node-input-server">Server</label>
26
52
  <input type="text" id="node-input-server">
27
53
  </div>
54
+ <div class="form-row">
55
+ <label for="node-input-direction">Direction</label>
56
+ <input type="text" id="node-input-direction" placeholder="inbound">
57
+ <input type="hidden" id="node-input-directionType">
58
+ </div>
59
+ <div class="form-row">
60
+ <label for="node-input-from">From</label>
61
+ <input type="text" id="node-input-from" placeholder="calling number">
62
+ <input type="hidden" id="node-input-fromType">
63
+ </div>
64
+ <div class="form-row">
65
+ <label for="node-input-to">To</label>
66
+ <input type="text" id="node-input-to" placeholder="called number">
67
+ <input type="hidden" id="node-input-toType">
68
+ </div>
69
+ <div class="form-row">
70
+ <label for="node-input-callStatus">Call Status</label>
71
+ <input type="text" id="node-input-callStatus" placeholder="in-progress">
72
+ <input type="hidden" id="node-input-callStatusType">
73
+ </div>
28
74
  </script>
29
75
 
30
76
  <!-- Help Text -->
@@ -1,4 +1,5 @@
1
1
  const bent = require("bent");
2
+ var { v_resolve } = require("./libs");
2
3
 
3
4
  module.exports = function (RED) {
4
5
  function get_calls(config) {
@@ -7,10 +8,25 @@ module.exports = function (RED) {
7
8
  const server = RED.nodes.getNode(config.server);
8
9
  const { accountSid, apiToken } = server.credentials;
9
10
  node.on("input", async (msg, send, done) => {
11
+ const data = {
12
+ direction: v_resolve(
13
+ config.direction,
14
+ config.directionType,
15
+ this.context(),
16
+ msg
17
+ ),
18
+ from: v_resolve(config.from, config.fromType, this.context(), msg),
19
+ to: v_resolve(config.to, config.toType, this.context(), msg),
20
+ callStatus: v_resolve(config.callStatus, config.callStatusType, this.context(), msg),
21
+ };
22
+ Object.keys(data).forEach(
23
+ (k) => data[k] == null || (data[k] == '' && delete data[k])
24
+ );
25
+ const params = new URLSearchParams(data).toString();
10
26
  const req = bent(
11
- `${server.url}/v1/Accounts/${accountSid}/Calls`,
12
- "GET",
13
- "json",
27
+ `${server.url}/v1/Accounts/${accountSid}/Calls${ params ? '?' + params : ''}`,
28
+ 'GET',
29
+ 'json',
14
30
  {
15
31
  Authorization: `Bearer ${apiToken}`,
16
32
  }