-
Notifications
You must be signed in to change notification settings - Fork 2
/
iotbnb.js
executable file
·123 lines (103 loc) · 3.52 KB
/
iotbnb.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
module.exports = function(RED) {
function iotbnb(n) {
RED.nodes.createNode(this,n);
var node = this;
this.on('input', function(msg) {
var path_InfoItem, token, operations, type1, reputation, price;
var iotbnbcons = require('node-red-contrib-iotbnb/iotbnbcons/iotbnbcons.js');
var omiN = new iotbnbcons();
if(typeof msg.operations!="undefined"){
operations= n.operations || msg.operations;
}
else{
operations= n.operations;
}
if (n.latitude=="" && typeof msg.latitude=="undefined"){
latitude="";
}
else{
latitude=n.latitude || msg.latitude;
}
if (n.longitude=="" && typeof msg.longitude=="undefined"){
longitude="";
}
else{
longitude=n.longitude || msg.longitude;
}
if (n.radius=="" && typeof msg.radius=="undefined"){
radius="100";
}
else{
radius=n.radius || msg.radius;
}
if (n.type1=="" && typeof msg.type1=="undefined"){
type1="all";
}
else{
type1=n.type1 || msg.type1;
}
if (n.price=="" && typeof msg.price=="undefined"){
price=0;
}
else{
price=n.price || msg.price;
}
if (n.reputation=="" && typeof msg.reputation=="undefined"){
reputation="all";
}
else{
reputation=n.reputation || msg.reputation;
}
if (n.service=="" && typeof msg.service=="undefined"){
service="Objects/";
}
else{
service=n.service || msg.service;
}
var options = {
operations: operations,
latitude: latitude,
longitude: longitude,
radius: radius,
type1: type1,
price: price,
reputation: reputation,
service: service
};
/*
console.log("---=====//////////////-----");
console.log(operations);
console.log(type1);
console.log(price);
console.log(reputation);
console.log("---=====//////////////-----");
*/
if (operations == "getAllServices"){
var oper_type="";
omiN.callMethod(options, function(err, events) {
msg.payload = events;
msg.err = err;
node.send(msg);
});
}
else if (operations == "searchServices"){
omiN.callMethod(options, function(err, events) {
msg.payload = events;
msg.err = err;
node.send(msg);
});
}
else if (operations == "getServiceAccessInformation"){
omiN.callMethod(options, function(err, events) {
msg.payload = events;
msg.err = err;
node.send(msg);
});
}
else{
node.send("There is a problem because no operation has been selected");
}
});
}
RED.nodes.registerType("iotbnb",iotbnb);
};