lelylan-rb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +26 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -0
- data/Guardfile +5 -0
- data/LICENSE.md +1 -0
- data/README.md +218 -0
- data/Rakefile +21 -0
- data/lelylan_rb.gemspec +36 -0
- data/lib/faraday/response/raise_http_error.rb +35 -0
- data/lib/lelylan.rb +26 -0
- data/lib/lelylan/authentication.rb +11 -0
- data/lib/lelylan/client.rb +47 -0
- data/lib/lelylan/client/categories.rb +112 -0
- data/lib/lelylan/client/consumptions.rb +93 -0
- data/lib/lelylan/client/devices.rb +211 -0
- data/lib/lelylan/client/functions.rb +118 -0
- data/lib/lelylan/client/histories.rb +42 -0
- data/lib/lelylan/client/locations.rb +92 -0
- data/lib/lelylan/client/properties.rb +115 -0
- data/lib/lelylan/client/statuses.rb +110 -0
- data/lib/lelylan/client/types.rb +109 -0
- data/lib/lelylan/configuration.rb +65 -0
- data/lib/lelylan/connection.rb +33 -0
- data/lib/lelylan/error.rb +34 -0
- data/lib/lelylan/request.rb +70 -0
- data/lib/lelylan/version.rb +15 -0
- data/spec/faraday/response_spec.rb +37 -0
- data/spec/fixtures/categories.json +7 -0
- data/spec/fixtures/category.json +7 -0
- data/spec/fixtures/consumption.json +11 -0
- data/spec/fixtures/consumptions.json +11 -0
- data/spec/fixtures/device.json +25 -0
- data/spec/fixtures/devices.json +25 -0
- data/spec/fixtures/function.json +15 -0
- data/spec/fixtures/functions.json +15 -0
- data/spec/fixtures/histories.json +16 -0
- data/spec/fixtures/history.json +16 -0
- data/spec/fixtures/location.json +55 -0
- data/spec/fixtures/locations.json +18 -0
- data/spec/fixtures/oauth2/refresh.json +6 -0
- data/spec/fixtures/oauth2/token.json +6 -0
- data/spec/fixtures/pending.json +12 -0
- data/spec/fixtures/properties.json +9 -0
- data/spec/fixtures/property.json +9 -0
- data/spec/fixtures/status.json +24 -0
- data/spec/fixtures/statuses.json +24 -0
- data/spec/fixtures/type.json +94 -0
- data/spec/fixtures/types.json +88 -0
- data/spec/helper.rb +71 -0
- data/spec/lelylan/client/categories_spec.rb +178 -0
- data/spec/lelylan/client/consumptions_spec.rb +150 -0
- data/spec/lelylan/client/devices_spec.rb +342 -0
- data/spec/lelylan/client/functions_spec.rb +184 -0
- data/spec/lelylan/client/histories_spec.rb +64 -0
- data/spec/lelylan/client/locations_spec.rb +155 -0
- data/spec/lelylan/client/properties_spec.rb +184 -0
- data/spec/lelylan/client/statuses_spec.rb +184 -0
- data/spec/lelylan/client/types_spec.rb +184 -0
- data/spec/lelylan/client_spec.rb +32 -0
- data/spec/lelylan/oauth2_spec.rb +54 -0
- data/spec/lelylan_spec.rb +32 -0
- metadata +351 -0
@@ -0,0 +1,112 @@
|
|
1
|
+
module Lelylan
|
2
|
+
class Client
|
3
|
+
module Categories
|
4
|
+
|
5
|
+
# Public: Returns extended information for a given category identified from its URI.
|
6
|
+
# Find more at {http://dev.lelylan.com/rest/types/categories/#get Lelylan Dev Center}.
|
7
|
+
#
|
8
|
+
# category - A String that represent the category URI.
|
9
|
+
#
|
10
|
+
# Returns Hashie The category.
|
11
|
+
#
|
12
|
+
# Examples
|
13
|
+
#
|
14
|
+
# category = "http://api.lelylan.com/categories/4dcb9e23d033a9088902200a"
|
15
|
+
# client.category(category)
|
16
|
+
#
|
17
|
+
def category(category)
|
18
|
+
get("/categories/#{find_id(category)}")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Public: Returns a list of categories.
|
22
|
+
# Find more at {http://dev.lelylan.com/rest/types/categories/#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/categories/#all API doc} for the accepted options.
|
26
|
+
#
|
27
|
+
# Returns Hashie List of categories.
|
28
|
+
#
|
29
|
+
# Examples
|
30
|
+
#
|
31
|
+
# # Retrurns the first 10 categories
|
32
|
+
# client.categories(per: 10)
|
33
|
+
#
|
34
|
+
# # Returns the categories where the name match with the desired string
|
35
|
+
# client.categories(name: 'Lighting')
|
36
|
+
#
|
37
|
+
def categories(options = {})
|
38
|
+
get("/categories", options)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Public: Returns a list of all public categories.
|
42
|
+
# Find more at {http://dev.lelylan.com/rest/categories/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/categories/#all API doc} for the accepted options.
|
46
|
+
#
|
47
|
+
# Returns Hashie List of categories.
|
48
|
+
#
|
49
|
+
# Examples
|
50
|
+
#
|
51
|
+
# # Retrurns the first 10 public categories
|
52
|
+
# client.public_categories(per: 10)
|
53
|
+
#
|
54
|
+
def public_categories(options = {})
|
55
|
+
get("/categories/public", options)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Public: Create a category and returns extended information for it.
|
59
|
+
# Find more at {http://dev.lelylan.com/rest/types/categories/#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/categories/#create API doc} for the accepted options.
|
63
|
+
#
|
64
|
+
# Returns Hashie The created category.
|
65
|
+
#
|
66
|
+
# Examples
|
67
|
+
#
|
68
|
+
# client.create_category(name: 'Lighting')
|
69
|
+
#
|
70
|
+
def create_category(options = {})
|
71
|
+
post("/categories", options)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Public: Update a category identified from its URI and returns extended information for it.
|
75
|
+
# Find more at {http://dev.lelylan.com/rest/types/categories/#update Lelylan Dev Center}.
|
76
|
+
#
|
77
|
+
# category - A String that represents the category URI.
|
78
|
+
# options - The Hash option used to update the resource (default: {}).
|
79
|
+
# Check out the {http://dev.lelylan.com/rest/types/categories/#update API doc} for the accepted options.
|
80
|
+
#
|
81
|
+
# Returns Hashie The updated category.
|
82
|
+
#
|
83
|
+
# Examples
|
84
|
+
#
|
85
|
+
# category = "http://api.lelylan.com/categories/4dcb9e23d033a9088902200a"
|
86
|
+
# client.update_category(category, name: 'Lighting RGB')
|
87
|
+
#
|
88
|
+
def update_category(category, options = {})
|
89
|
+
put("/categories/#{find_id(category)}", options)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Public: Delete a category identified from its URI and returns extended information for it.
|
93
|
+
# Find more at {http://dev.lelylan.com/rest/types/categories/#delete Lelylan Dev Center}.
|
94
|
+
#
|
95
|
+
# category - A String that represent the category URI.
|
96
|
+
#
|
97
|
+
# Returns Hashie The deleted category.
|
98
|
+
#
|
99
|
+
# Examples
|
100
|
+
#
|
101
|
+
# category = "http://api.lelylan.com/categories/4dcb9e23d033a9088902200a"
|
102
|
+
# client.delete_category(category)
|
103
|
+
#
|
104
|
+
def delete_category(category)
|
105
|
+
delete("/categories/#{find_id(category)}")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
|
@@ -0,0 +1,93 @@
|
|
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
|
@@ -0,0 +1,211 @@
|
|
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
|
@@ -0,0 +1,118 @@
|
|
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
|
+
|