-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHueClient.js
36 lines (30 loc) · 852 Bytes
/
HueClient.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
var hueClient = {
init: function(controllerUrl){
this.controllerUrl = controllerUrl;
//define endpoints
this.rootEndpoint = "/api/";
this.fullStateByUsernameEndpoint = "/api/%s";
this.lightsByUsernameEndpoint = "/api/%s/lights";
},
get: function(path){
var uri = this.controllerUrl + path;
console.log("uri: " + uri);
var request = jQuery.ajax({
type: "GET",
dataType: "json",
url: uri,
async: false
});
return request;
},
getLightsByUsername: function(username){
var path = this.lightsByUsernameEndpoint.replace("%s",username);
console.log("path: " + path);
return this.get(path);
},
getFullStateByUsername: function(username){
var path = this.fullStateByUsernameEndpoint.replace("%s",username);
console.log("path: " + path);
return this.get(path);
}
};