-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathtest.js
48 lines (38 loc) · 1.54 KB
/
test.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
var WinkAPI = require('./winkapi')
, util = require('util')
;
var clientID = '...'
, clientSecret = '...'
, userName = '...'
, passPhrase = '...'
, winkapi
;
winkapi = new WinkAPI.WinkAPI({ clientID: clientID, clientSecret: clientSecret }).login(userName, passPhrase, function(err) {
if (!!err) return console.log('login error: ' + err.message);
winkapi.getUser(function(err, user) {
if (!!err) return console.log('getUser: ' + err.message);
console.log('user:'); console.log(user);
}).getDevices(function(err, devices) {
var i;
if (!!err) return console.log('getDevices: ' + err.message);
console.log('devices:');
for (i = 0; i < devices.length; i++) {
console.log('device #' + i);
console.log(util.inspect(devices[i], { depth: null }));
}
}).getIcons(function(err, icons) {
if (!!err) return console.log('getIcons: ' + err.message);
console.log('icons:'); console.log(icons);
}).getChannels(function(err, channels) {
if (!!err) return console.log('getChannels: ' + err.message);
console.log('channels:'); console.log(channels);
}).getDialTemplates(function(err, dialTemplates) {
if (!!err) return console.log('getDialTemplates: ' + err.message);
console.log('dialTemplates:'); console.log(dialTemplates);
}).getServices(function(err, services) {
if (!!err) return console.log('getServices: ' + err.message);
console.log('services:'); console.log(services);
});
}).on('error', function(err) {
console.log('background error: ' + err.message);
});