lelylan-rb 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. data/.gitignore +1 -0
  2. data/CHANGELOG.md +6 -2
  3. data/Gemfile +1 -3
  4. data/Guardfile +1 -1
  5. data/README.md +155 -84
  6. data/Rakefile +2 -15
  7. data/images/bg_hr.png +0 -0
  8. data/images/blacktocat.png +0 -0
  9. data/images/icon_download.png +0 -0
  10. data/images/sprite_download.png +0 -0
  11. data/index.html +74 -0
  12. data/javascripts/main.js +1 -0
  13. data/lelylan_rb.gemspec +12 -13
  14. data/lib/lelylan/client.rb +20 -23
  15. data/lib/lelylan/client/device.rb +121 -0
  16. data/lib/lelylan/client/function.rb +73 -0
  17. data/lib/lelylan/client/history.rb +28 -0
  18. data/lib/lelylan/client/location.rb +62 -0
  19. data/lib/lelylan/client/physical.rb +34 -0
  20. data/lib/lelylan/client/profile.rb +17 -0
  21. data/lib/lelylan/client/property.rb +75 -0
  22. data/lib/lelylan/client/status.rb +74 -0
  23. data/lib/lelylan/client/subscription.rb +62 -0
  24. data/lib/lelylan/client/type.rb +73 -0
  25. data/lib/lelylan/configuration.rb +4 -4
  26. data/lib/lelylan/connection.rb +9 -2
  27. data/lib/lelylan/request.rb +2 -16
  28. data/lib/lelylan/version.rb +1 -1
  29. data/spec/fixtures/profile.json +8 -0
  30. data/spec/fixtures/subscription.json +10 -0
  31. data/spec/fixtures/subscriptions.json +10 -0
  32. data/spec/lelylan/client/device_spec.rb +234 -0
  33. data/spec/lelylan/client/function_spec.rb +158 -0
  34. data/spec/lelylan/client/history_spec.rb +48 -0
  35. data/spec/lelylan/client/location_spec.rb +122 -0
  36. data/spec/lelylan/client/physical_spec.rb +27 -0
  37. data/spec/lelylan/client/profile_spec.rb +27 -0
  38. data/spec/lelylan/client/property_spec.rb +159 -0
  39. data/spec/lelylan/client/status_spec.rb +158 -0
  40. data/spec/lelylan/client/subscription_spec.rb +144 -0
  41. data/spec/lelylan/client/type_spec.rb +158 -0
  42. data/spec/lelylan/oauth2_spec.rb +13 -19
  43. data/stylesheets/pygment_trac.css +70 -0
  44. data/stylesheets/stylesheet.css +431 -0
  45. metadata +75 -114
  46. data/lib/lelylan/client/categories.rb +0 -112
  47. data/lib/lelylan/client/consumptions.rb +0 -93
  48. data/lib/lelylan/client/devices.rb +0 -211
  49. data/lib/lelylan/client/functions.rb +0 -118
  50. data/lib/lelylan/client/histories.rb +0 -42
  51. data/lib/lelylan/client/locations.rb +0 -92
  52. data/lib/lelylan/client/properties.rb +0 -115
  53. data/lib/lelylan/client/statuses.rb +0 -110
  54. data/lib/lelylan/client/types.rb +0 -109
  55. data/spec/lelylan/client/categories_spec.rb +0 -178
  56. data/spec/lelylan/client/consumptions_spec.rb +0 -150
  57. data/spec/lelylan/client/devices_spec.rb +0 -342
  58. data/spec/lelylan/client/functions_spec.rb +0 -184
  59. data/spec/lelylan/client/histories_spec.rb +0 -64
  60. data/spec/lelylan/client/locations_spec.rb +0 -155
  61. data/spec/lelylan/client/properties_spec.rb +0 -184
  62. data/spec/lelylan/client/statuses_spec.rb +0 -184
  63. data/spec/lelylan/client/types_spec.rb +0 -184
@@ -1,93 +0,0 @@
1
- module Lelylan
2
- class Client
3
- module Consumptions
4
-
5
- # Public: Returns extended information for a given consumption identified from its URI.
6
- # Find more at {http://dev.lelylan.com/rest/devices/consumptions/#get Lelylan Dev Center}.
7
- #
8
- # consumption - A String that represent the consumption URI.
9
- #
10
- # Returns Hashie The consumption.
11
- #
12
- # Examples
13
- #
14
- # consumption = "http://api.lelylan.com/consumption/4dcb9e23d033a9088902200a"
15
- # client.consumption(consumption)
16
- #
17
- def consumption(consumption)
18
- get("/consumptions/#{find_id(consumption)}")
19
- end
20
-
21
- # Public: Returns extended information for a given consumption identified from its URI.
22
- # Find more at {http://dev.lelylan.com/rest/devices/consumptions/#all Lelylan Dev Center}.
23
- #
24
- # options - The Hash option used to refine the search (default: {}).
25
- # Check out the {http://dev.lelylan.com/rest/devices/consumptions/#all API doc} for the accepted options.
26
- #
27
- # Returns Hashie List of consumptions.
28
- #
29
- # Examples
30
- #
31
- # # Retrurns the first 10 consumptions
32
- # client.consumptions(per: 10)
33
- #
34
- # # Returns the device consumptions from yesterday till now
35
- # client.consumptions(from: 'yesterday')
36
- #
37
- def consumptions(options = {})
38
- get("/consumptions", options)
39
- end
40
-
41
- # Public: Create a consumption and returns extended information for it.
42
- # Find more at {http://dev.lelylan.com/rest/devices/consumptions/#create Lelylan Dev Center}.
43
- #
44
- # options - The Hash option used to create the resource (default: {}).
45
- # Check out the {http://dev.lelylan.com/rest/devices/consumptions/#create API doc} for the accepted options.
46
- #
47
- # Returns Hashie The created consumption.
48
- #
49
- # Examples
50
- #
51
- # device = "http://api.lelylan.com/devices/4dcb9e23d033a9088900000a"
52
- # client.create_conumption(device: device, value: 0.05, occur_at: "2025-08-17 07:50:16 +0200", duration: "1")
53
- #
54
- def create_consumption(options = {})
55
- post("/consumptions", options)
56
- end
57
-
58
- # Public: Update a consumption identified from its URI and returns extended information for it.
59
- # Find more at {http://dev.lelylan.com/rest/devices/consumptions/#update Lelylan Dev Center}.
60
- #
61
- # consumption - A String that represent the consumption URI.
62
- # options - The Hash option used to update the resource (default: {}).
63
- # Check out the {http://dev.lelylan.com/rest/devices/consumptions/#update API doc} for the accepted options.
64
- #
65
- # Returns Hashie The updated consumption.
66
- #
67
- # Examples
68
- #
69
- # consumption = "http://api.lelylan.com/consumptions/4dcb9e23d033a9088902200a"
70
- # client.update_consumption(consumption, value: '0.04')
71
- #
72
- def update_consumption(consumption, options = {})
73
- put("/consumptions/#{find_id(consumption)}", options)
74
- end
75
-
76
- # Public: Delete a consumption identified from its URI and returns extended information for it.
77
- # Find more at {http://dev.lelylan.com/rest/devices/consumptions/#delete Lelylan Dev Center}.
78
- #
79
- # consumption - A String that represent the consumption URI.
80
- #
81
- # Returns Hashie The deleted consumption.
82
- #
83
- # Examples
84
- #
85
- # consumption = "http://api.lelyla.com/consumptions/4dcb9e23d033a9088902200a"
86
- # client.delete_consumption(consumption)
87
- #
88
- def delete_consumption(consumption)
89
- delete("/consumptions/#{find_id(consumption)}")
90
- end
91
- end
92
- end
93
- end
@@ -1,211 +0,0 @@
1
- module Lelylan
2
- class Client
3
- module Devices
4
-
5
- # Public: Returns extended information for a given device
6
- # identified from its URI.
7
- # Find more at {http://dev.lelylan.com/rest/devices/core/#get Lelylan Dev Center}.
8
- #
9
- # device - A String that represent the device URI.
10
- #
11
- # Returns Hashie The device.
12
- #
13
- # Examples
14
- #
15
- # device = "http://api.lelylan.com/devices/4dcb9e23d033a9088900000a"
16
- # client.device(device)
17
- #
18
- def device(device)
19
- get("/devices/#{find_id(device)}")
20
- end
21
-
22
- # Public: Returns a list of owned devices.
23
- # Find more at {http://dev.lelylan.com/rest/devices/core/#all Lelylan Dev Center}.
24
- #
25
- # options - The Hash option used to refine the search (default: {}).
26
- # Check out the {http://dev.lelylan.com/rest/devices/core/#all API doc} for the accepted options.
27
- #
28
- # Returns Hashie List of devices.
29
- #
30
- # Examples
31
- #
32
- # # Returns the first 25 devices
33
- # client.devices
34
- #
35
- # # Retrurns the first 10 devices
36
- # client.devices(per: 10)
37
- #
38
- # # Returns the devices of a specific type
39
- # type = "http://api.lelylan.com/types/4dcb9e23d033a9088900023a"
40
- # client.devices(type: type)
41
- #
42
- def devices(options = {})
43
- get("/devices", options)
44
- end
45
-
46
- # Public: Create a device and returns extended information for it.
47
- # Find more at {http://dev.lelylan.com/rest/devices/core/#create Lelylan Dev Center}.
48
- #
49
- # options - The Hash option used to create the resource (default: {}).
50
- # Check out the {http://dev.lelylan.com/rest/devices/core/#create API doc} for the accepted options.
51
- #
52
- # Returns Hashie The created device.
53
- #
54
- # Examples
55
- #
56
- # type = "http://api.lelyla.com/types/4dcb9e23d033a9088900023a"
57
- # client.create_device(name: "Dimmer", type: type)
58
- #
59
- def create_device(options = {})
60
- post("/devices", options)
61
- end
62
-
63
- # Public: Update a device identified from its URI and returns extended information for it.
64
- # Find more at {http://dev.lelylan.com/rest/devices/core/#update Lelylan Dev Center}.
65
- #
66
- # device - A String that represent the device URI.
67
- # options - The Hash option used to update the resource (default: {}).
68
- # Check out the {http://dev.lelylan.com/rest/devices/core/#update API doc} for the accepted options.
69
- #
70
- # Returns Hashie The updated device.
71
- #
72
- # Examples
73
- #
74
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
75
- # client.update_device(device, name: 'Closed dimmer')
76
- #
77
- def update_device(device, options = {})
78
- put("/devices/#{find_id(device)}", options)
79
- end
80
-
81
- # Public: Delete a device identified from its URI and returns extended information for it.
82
- # Find more at {http://dev.lelylan.com/rest/devices/core/#delete Lelylan Dev Center}.
83
- #
84
- # device - A String that represent the device URI.
85
- #
86
- # Returns Hashie The deleted device.
87
- #
88
- # Examples
89
- #
90
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
91
- # client.delete_device(device)
92
- #
93
- def delete_device(device)
94
- delete("/devices/#{find_id(device)}")
95
- end
96
-
97
- # Public: Execute a function on a device identified from its URI and returns extended representation for it.
98
- # Find more at {http://dev.lelylan.com/rest/devices/functions/#update Lelylan Dev Center}.
99
- #
100
- # device - A String that represent the device URI.
101
- # function - A string that represent the function URI to execute
102
- # options - The Hash option used to update the resource properties (default: {}).
103
- # Check out the {http://dev.lelylan.com/rest/devices/functions/#update API doc} for the accepted options.
104
- #
105
- # Returns Hashie The device with the updated properties.
106
- #
107
- # Examples
108
- #
109
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
110
- # function = "http://api.lelyla.com/functions/4dcb9e23d033a9088900020a"
111
- # properties = [{uri: "http://api.lelylan.com/functions/4dcb9e23d033a9088900020a", value: "50"}]
112
- #
113
- # client.execute(device, function, properties: properties)
114
- #
115
- def execute(device, function, options={})
116
- put("/devices/#{find_id(device)}/functions?uri=#{function}", options)
117
- end
118
-
119
- # Public: Update properties on a device identified from its URI and returns extended representation for it.
120
- # Find more at {http://dev.lelylan.com/rest/devices/properties/#update Lelylan Dev Center}.
121
- #
122
- # device - A String that represent the device URI.
123
- # options - The Hash option used to update the resource properties (default: {}).
124
- # Check out the {http://dev.lelylan.com/rest/devices/properties/#update API doc} for the accepted options.
125
- #
126
- # Returns Hashie The device with the updated properties.
127
- #
128
- # Examples
129
- #
130
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
131
- # properties = [{uri: "http://api.lelylan.com/functions/4dcb9e23d033a9088900020a", value: "50"}]
132
- #
133
- # client.update_properties(device, function, properties: properties)
134
- #
135
- def update_properties(device, options={})
136
- put("/devices/#{find_id(device)}/properties", options)
137
- end
138
-
139
- # Public: Create the connection between a device and a physical device.
140
- # Find more at {http://dev.lelylan.com/rest/devices/physical/#update Lelylan Dev Center}.
141
- #
142
- # device - A String that represent the device URI.
143
- # options - The Hash option containing the physcial device to connect (default: {}). Check out the {http://dev.lelylan.com/rest/devices/physical/#update API doc} for the accepted options.
144
- #
145
- # Returns Hashie The device with the connected physical device.
146
- #
147
- # Examples
148
- #
149
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
150
- # physical = "http://node.lelylan.com/devices/8ecfd3a9b9a0e4"
151
- #
152
- # client.update_properties(device, uri: physical)
153
- #
154
- def connect_physical(device, options={})
155
- put("/devices/#{find_id(device)}/physical", options)
156
- end
157
-
158
- # Public: Delete the connection between a device and a physical device.
159
- # Find more at {http://dev.lelylan.com/rest/devices/physical/#delete Lelylan Dev Center}.
160
- #
161
- # device - A String that represent the device URI.
162
- #
163
- # Returns Hashie The device with the removed connection to the physical device.
164
- #
165
- # Examples
166
- #
167
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
168
- # client.update_properties(device)
169
- #
170
- def disconnect_physical(device, options={})
171
- delete("/devices/#{find_id(device)}/physical")
172
- end
173
-
174
- # Public: Returns the pending resource for a given device identified from its URI.
175
- # Find more at {http://dev.lelylan.com/rest/devices/pending/#get Lelylan Dev Center}.
176
- #
177
- # device - A String that represent the device URI.
178
- #
179
- # Returns Hashie The pending resource. What does {http://dev.lelylan.com/rest/devices/pending/ pending} mean?
180
- #
181
- # Examples
182
- #
183
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
184
- # client.pending(device)
185
- #
186
- def pending(device)
187
- get("/devices/#{find_id(device)}/pending")
188
- end
189
-
190
- # Public: Update the pending resource for a given device identified from its URI.
191
- # Find more at {http://dev.lelylan.com/rest/devices/pending/#update Lelylan Dev Center}.
192
- #
193
- # device - A String that represent the device URI.
194
- # pending - A String that represent the pending phase (start, update and close).
195
- # options - The Hash option used to update the resource properties (default: {}).
196
- # Check out the {http://dev.lelylan.com/rest/devices/properties/#update API doc} for the accepted options.
197
- #
198
- # Returns Hashie The updated pending resource. What does {http://dev.lelylan.com/rest/devices/pending/ pending} mean?
199
- #
200
- # Examples
201
- #
202
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900000a"
203
- # properties = [{uri: "http://api.lelylan.com/functions/4dcb9e23d033a9088900020a", value: "50"}]
204
- # client.update_pending(device, 'start', properties: properties)
205
- #
206
- def update_pending(device, options={})
207
- put("/devices/#{find_id(device)}/pending", options)
208
- end
209
- end
210
- end
211
- end
@@ -1,118 +0,0 @@
1
- module Lelylan
2
- class Client
3
- module Functions
4
-
5
- # Public: Returns extended information for a given function identified from its URI.
6
- # Find more at {http://dev.lelylan.com/rest/types/functions/#get Lelylan Dev Center}.
7
- #
8
- # function - A String that represent the function URI.
9
- #
10
- # Returns Hashie The function.
11
- #
12
- # Examples
13
- #
14
- # function = "http://api.lelylan.com/functions/4dcb9e23d033a9088902200a"
15
- # client.function(function)
16
- #
17
- def function(function)
18
- get("/functions/#{find_id(function)}")
19
- end
20
-
21
- # Public: Returns a list of functions.
22
- # Find more at {http://dev.lelylan.com/rest/types/functions/#all Lelylan Dev Center}.
23
- #
24
- # options - The Hash option used to refine the search (default: {}).
25
- # Check out the {http://dev.lelylan.com/rest/types/functions/#all API doc} for the accepted options.
26
- #
27
- # Returns Hashie List of functions.
28
- #
29
- # Examples
30
- #
31
- # # Retrurns the first 10 functions
32
- # client.functions(per: 10)
33
- #
34
- # # Returns the functions where the name match with the desired string
35
- # client.functions(name: 'Turn on')
36
- #
37
- def functions(options = {})
38
- get("/functions", options)
39
- end
40
-
41
- # Public: Returns a list of all public functions.
42
- # Find more at {http://dev.lelylan.com/rest/functions/core/#all Lelylan Dev Center}.
43
- #
44
- # options - The Hash option used to refine the search (default: {}).
45
- # Check out the {http://dev.lelylan.com/rest/devices/functions/#all API doc} for the accepted options.
46
- #
47
- # Returns Hashie List of functions.
48
- #
49
- # Examples
50
- #
51
- # # Retrurns the first 10 public functions
52
- # client.public_functions(per: 10)
53
- #
54
- def public_functions(options = {})
55
- get("/functions/public", options)
56
- end
57
-
58
- # Public: Create a function and returns extended information for it.
59
- # Find more at {http://dev.lelylan.com/rest/types/functions/#create Lelylan Dev Center}.
60
- #
61
- # options - The Hash option used to create the resource (default: {}).
62
- # Check out the {http://dev.lelylan.com/rest/types/functions/#create API doc} for the accepted options.
63
- #
64
- # Returns Hashie The created function.
65
- #
66
- # Examples
67
- #
68
- # # device properties
69
- # status = https://api.lelylan.com/properties/4dcb9e23d033a9088902200b"
70
- # intensity = https://api.lelylan.com/properties/4dcb9e23d033a9088902200c"
71
- # # values the function is going to set
72
- # properties = [{uri: status, value: 'on'}, {uri: intensity}]
73
- # # create the function
74
- # client.create_function(name: 'Set intensity', properties: properties)
75
- #
76
- def create_function(options = {})
77
- post("/functions", options)
78
- end
79
-
80
- # Public: Update a function identified from its URI and returns extended information for it.
81
- # Find more at {http://dev.lelylan.com/rest/types/functions/#update Lelylan Dev Center}.
82
- #
83
- # function - A String that represents the function URI.
84
- # options - The Hash option used to update the resource (default: {}).
85
- # Check out the {http://dev.lelylan.com/rest/types/functions/#update API doc} for the accepted options.
86
- #
87
- # Returns Hashie The updated function.
88
- #
89
- # Examples
90
- #
91
- # function = "http://api.lelylan.com/functions/4dcb9e23d033a9088902200d"
92
- # client.update_function(function, name: 'Set intensity')
93
- #
94
- def update_function(function, options = {})
95
- put("/functions/#{find_id(function)}", options)
96
- end
97
-
98
- # Public: Delete a function identified from its URI and returns extended information for it.
99
- # Find more at {http://dev.lelylan.com/rest/types/functions/#delete Lelylan Dev Center}.
100
- #
101
- # function - A String that represent the function URI.
102
- #
103
- # Returns Hashie The deleted function.
104
- #
105
- # Examples
106
- #
107
- # function = "http://api.lelylan.com/functions/4dcb9e23d033a9088902200a"
108
- # client.delete_function(function)
109
- #
110
- def delete_function(function)
111
- delete("/functions/#{find_id(function)}")
112
- end
113
- end
114
- end
115
- end
116
-
117
-
118
-
@@ -1,42 +0,0 @@
1
- module Lelylan
2
- class Client
3
- module Histories
4
-
5
- # Public: Returns extended information for a given history identified from its URI.
6
- # Find more at {http://dev.lelylan.com/rest/devices/history/#get Lelylan Dev Center}.
7
- #
8
- # history - A String that represents the history URI.
9
- #
10
- # Returns Hashie The history resource.
11
- #
12
- # Examples
13
- #
14
- # history = "http://api.lelylan.com/histories/4dcb9e23d033a9088900200f"
15
- # client.history(history)
16
- #
17
- def history(history)
18
- get("/histories/#{find_id(history)}")
19
- end
20
-
21
- # Public: Returns a list of history resources for a given device identified from its URI.
22
- # Find more at {http://dev.lelylan.com/rest/devices/history/#all Lelylan Dev Center}.
23
- #
24
- # device - A String that represents the device URI.
25
- # options - The Hash option used to refine the search (default: {}).
26
- # Check out the {http://dev.lelylan.com/rest/devices/history/#all API doc} for the accepted options.
27
- #
28
- # Returns Hashie List of histories.
29
- #
30
- # Examples
31
- #
32
- # # Returns the first 10 histories for a specific device)
33
- # device = "http://api.lelyla.com/devices/4dcb9e23d033a9088900023b"
34
- # client.histories(device, per: 10)
35
- #
36
- #
37
- def histories(device, options = {})
38
- get("/devices/#{find_id(device)}/histories", options)
39
- end
40
- end
41
- end
42
- end