-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
67 lines (53 loc) · 1.8 KB
/
example.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
const GiraX1RestClient = require('./lib/gira-x1-rest-client');
(async () => {
try {
// register client
let response = await GiraX1RestClient.register({
address: '192.168.33.33',
username: 'username',
password: 'test',
});
if (response.status != 201) throw new Error('Error while authenticating');
const token = response.data.token;
// Get Licences
response = await GiraX1RestClient.getLicences({
address: '192.168.33.33',
token: token,
});
if (response.status != 200) throw new Error('Error while getting licences');
const licences = response.data;
// get uiConfigUid
response = await GiraX1RestClient.getUiConfigUi({
address: '192.168.33.33',
token: token,
});
if (response.status != 200)
throw new Error('Error while getting UI configuration UID');
const uiConfigUid = response.data.uid;
// get uiConfig
response = await GiraX1RestClient.getUiConfig({
address: '192.168.33.33',
token: token,
});
if (response.status != 200)
throw new Error('Error while getting UI configuration');
const location = response.data.locations;
const functions = response.data.functions;
const trades = response.data.trades;
if (response.status != 200)
throw new Error('Error while getting UI configuration');
// get value for uid a01h (Büro Licht)
response = await GiraX1RestClient.getValueForUid(
{
address: '192.168.33.33',
token: token,
},
'a01h'
);
if (response.status != 200)
throw new Error('Error while getting UI configuration');
console.log(JSON.stringify(response.data.values));
} catch (error) {
console.log(error.message);
}
})();