-
Notifications
You must be signed in to change notification settings - Fork 10
/
dysonCloud.js
61 lines (51 loc) · 1.35 KB
/
dysonCloud.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
var request = require('request-promise-native');
var crypto = require('crypto');
class DysonCloud {
constructor() {
this.api = 'https://appapi.cp.dyson.com'
this.auth = {}
}
authenticate(email, password, country) {
if (!country) {
country = 'US'
}
var options = {
url: `${this.api}/v1/userregistration/authenticate?country=${country}`,
method: 'post',
body: {
Email: email,
Password: password
},
agentOptions: {
rejectUnauthorized: false
},
json: true
}
return request(options).then(info => {
this.auth = {
account: info.Account,
password: info.Password
}
return this.auth
})
}
logout() {
this.auth = {}
}
getCloudDevices() {
var options = {
url: `${this.api}/v2/provisioningservice/manifest`,
method: 'get',
auth: {
username: this.auth.account,
password: this.auth.password,
},
agentOptions: {
rejectUnauthorized: false
},
json: true
}
return request(options);
}
};
module.exports = DysonCloud;