-
Notifications
You must be signed in to change notification settings - Fork 16
/
api.js
41 lines (39 loc) · 1.04 KB
/
api.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
'use strict';
const Homey = require('homey');
const Tahoma = require('./lib/Tahoma');
module.exports = [
{
description: 'Authenticate TaHoma',
method: 'POST',
path: '/login/',
fn: function (args, callback) {
Tahoma.login(args.body.username, args.body.password)
.then(result => {
Homey.ManagerSettings.set('username', args.body.username);
Homey.ManagerSettings.set('password', args.body.password);
callback(null, result);
})
.catch(error => {
console.log(error.message, error.stack);
callback(error);
});
}
},
{
description: 'Log out of TaHoma',
method: 'POST',
path: '/logout/',
fn: function (args, callback) {
Tahoma.logout()
.then(result => {
Homey.ManagerSettings.unset('username');
Homey.ManagerSettings.unset('password');
callback(null, result);
})
.catch(error => {
console.log(error.message, error.stack);
callback(error);
});
}
}
];