losant_rest 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +23 -0
- data/.rbenv-version +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +2 -0
- data/LICENSE +21 -0
- data/README.md +237 -0
- data/Rakefile +12 -0
- data/docs/_schemas.md +6348 -0
- data/docs/accessToken.md +107 -0
- data/docs/accessTokens.md +68 -0
- data/docs/application.md +107 -0
- data/docs/applicationKey.md +115 -0
- data/docs/applicationKeys.md +81 -0
- data/docs/applications.md +76 -0
- data/docs/auth.md +104 -0
- data/docs/dashboard.md +107 -0
- data/docs/dashboards.md +76 -0
- data/docs/data.md +78 -0
- data/docs/device.md +300 -0
- data/docs/deviceRecipe.md +152 -0
- data/docs/deviceRecipes.md +81 -0
- data/docs/devices.md +117 -0
- data/docs/event.md +115 -0
- data/docs/events.md +153 -0
- data/docs/flow.md +261 -0
- data/docs/flows.md +81 -0
- data/docs/me.md +312 -0
- data/docs/org.md +279 -0
- data/docs/orgs.md +75 -0
- data/docs/webhook.md +115 -0
- data/docs/webhooks.md +81 -0
- data/examples/auth.rb +32 -0
- data/examples/list_devices.rb +45 -0
- data/lib/losant_rest/access_token.rb +122 -0
- data/lib/losant_rest/access_tokens.rb +80 -0
- data/lib/losant_rest/application.rb +122 -0
- data/lib/losant_rest/application_key.rb +128 -0
- data/lib/losant_rest/application_keys.rb +98 -0
- data/lib/losant_rest/applications.rb +94 -0
- data/lib/losant_rest/auth.rb +122 -0
- data/lib/losant_rest/client.rb +132 -0
- data/lib/losant_rest/dashboard.rb +122 -0
- data/lib/losant_rest/dashboards.rb +94 -0
- data/lib/losant_rest/data.rb +89 -0
- data/lib/losant_rest/device.rb +336 -0
- data/lib/losant_rest/device_recipe.rb +169 -0
- data/lib/losant_rest/device_recipes.rb +98 -0
- data/lib/losant_rest/devices.rb +139 -0
- data/lib/losant_rest/error.rb +12 -0
- data/lib/losant_rest/event.rb +128 -0
- data/lib/losant_rest/events.rb +183 -0
- data/lib/losant_rest/flow.rb +290 -0
- data/lib/losant_rest/flows.rb +98 -0
- data/lib/losant_rest/me.rb +362 -0
- data/lib/losant_rest/org.rb +314 -0
- data/lib/losant_rest/orgs.rb +92 -0
- data/lib/losant_rest/utils.rb +22 -0
- data/lib/losant_rest/version.rb +3 -0
- data/lib/losant_rest/webhook.rb +128 -0
- data/lib/losant_rest/webhooks.rb +98 -0
- data/lib/losant_rest.rb +43 -0
- data/losant_rest.gemspec +25 -0
- data/schemas/accessToken.json +52 -0
- data/schemas/accessTokenPatch.json +19 -0
- data/schemas/accessTokenPost.json +32 -0
- data/schemas/accessTokens.json +65 -0
- data/schemas/application.json +65 -0
- data/schemas/applicationKey.json +68 -0
- data/schemas/applicationKeyPatch.json +18 -0
- data/schemas/applicationKeyPost.json +36 -0
- data/schemas/applicationKeys.json +110 -0
- data/schemas/applicationPatch.json +16 -0
- data/schemas/applicationPost.json +23 -0
- data/schemas/applications.json +103 -0
- data/schemas/authedDevice.json +34 -0
- data/schemas/authedUser.json +18 -0
- data/schemas/dashboard.json +95 -0
- data/schemas/dashboardPatch.json +69 -0
- data/schemas/dashboardPost.json +76 -0
- data/schemas/dashboards.json +133 -0
- data/schemas/device.json +113 -0
- data/schemas/deviceCommand.json +20 -0
- data/schemas/deviceCommands.json +25 -0
- data/schemas/deviceCredentials.json +22 -0
- data/schemas/deviceLog.json +28 -0
- data/schemas/devicePatch.json +78 -0
- data/schemas/devicePost.json +81 -0
- data/schemas/deviceRecipe.json +106 -0
- data/schemas/deviceRecipeBulkCreate.json +15 -0
- data/schemas/deviceRecipeBulkCreatePost.json +19 -0
- data/schemas/deviceRecipePatch.json +87 -0
- data/schemas/deviceRecipePost.json +90 -0
- data/schemas/deviceRecipes.json +148 -0
- data/schemas/deviceState.json +30 -0
- data/schemas/deviceStates.json +35 -0
- data/schemas/deviceTagFilter.json +19 -0
- data/schemas/devices.json +155 -0
- data/schemas/disableTwoFactorAuth.json +20 -0
- data/schemas/enableTwoFactorAuth.json +21 -0
- data/schemas/error.json +12 -0
- data/schemas/event.json +115 -0
- data/schemas/eventPatch.json +20 -0
- data/schemas/eventPost.json +39 -0
- data/schemas/events.json +165 -0
- data/schemas/flow.json +137 -0
- data/schemas/flowLog.json +46 -0
- data/schemas/flowPatch.json +107 -0
- data/schemas/flowPost.json +110 -0
- data/schemas/flowStorageEntries.json +7 -0
- data/schemas/flowStorageEntry.json +16 -0
- data/schemas/flows.json +179 -0
- data/schemas/githubLogin.json +14 -0
- data/schemas/lastValueData.json +34 -0
- data/schemas/lastValueQuery.json +36 -0
- data/schemas/me.json +173 -0
- data/schemas/mePatch.json +43 -0
- data/schemas/multiDeviceCommand.json +45 -0
- data/schemas/org.json +81 -0
- data/schemas/orgInvitePost.json +24 -0
- data/schemas/orgInvites.json +36 -0
- data/schemas/orgMemberPatch.json +23 -0
- data/schemas/orgPatch.json +16 -0
- data/schemas/orgPost.json +19 -0
- data/schemas/orgs.json +119 -0
- data/schemas/recentItem.json +27 -0
- data/schemas/recentItemList.json +36 -0
- data/schemas/success.json +12 -0
- data/schemas/timeSeriesData.json +89 -0
- data/schemas/timeSeriesQuery.json +64 -0
- data/schemas/userCredentials.json +25 -0
- data/schemas/virtualButtonPress.json +14 -0
- data/schemas/webhook.json +52 -0
- data/schemas/webhookPatch.json +29 -0
- data/schemas/webhookPost.json +32 -0
- data/schemas/webhooks.json +94 -0
- data/test/basic_test.rb +67 -0
- data/test/test_helper.rb +14 -0
- metadata +239 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Device Resource
|
|
4
|
+
class Device
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Deletes a device
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} deviceId - ID associated with the device
|
|
15
|
+
# * {boolean} _actions - Return resource actions in response
|
|
16
|
+
# * {boolean} _links - Return resource link in response
|
|
17
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
18
|
+
#
|
|
19
|
+
# Responses:
|
|
20
|
+
# * 200 - If device was successfully deleted (https://api.losant.com/#/definitions/success)
|
|
21
|
+
#
|
|
22
|
+
# Errors:
|
|
23
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
24
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
25
|
+
def delete(params = {})
|
|
26
|
+
params = Utils.symbolize_hash_keys(params)
|
|
27
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
28
|
+
headers = {}
|
|
29
|
+
body = nil
|
|
30
|
+
|
|
31
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
32
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
33
|
+
|
|
34
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
35
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
36
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
37
|
+
|
|
38
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
|
|
39
|
+
|
|
40
|
+
@client.request(
|
|
41
|
+
method: :delete,
|
|
42
|
+
path: path,
|
|
43
|
+
query: query_params,
|
|
44
|
+
headers: headers,
|
|
45
|
+
body: body)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Retrieves information on a device
|
|
49
|
+
#
|
|
50
|
+
# Parameters:
|
|
51
|
+
# * {string} applicationId - ID associated with the application
|
|
52
|
+
# * {string} deviceId - ID associated with the device
|
|
53
|
+
# * {boolean} _actions - Return resource actions in response
|
|
54
|
+
# * {boolean} _links - Return resource link in response
|
|
55
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
56
|
+
#
|
|
57
|
+
# Responses:
|
|
58
|
+
# * 200 - Device information (https://api.losant.com/#/definitions/device)
|
|
59
|
+
#
|
|
60
|
+
# Errors:
|
|
61
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
62
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
63
|
+
def get(params = {})
|
|
64
|
+
params = Utils.symbolize_hash_keys(params)
|
|
65
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
66
|
+
headers = {}
|
|
67
|
+
body = nil
|
|
68
|
+
|
|
69
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
70
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
71
|
+
|
|
72
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
73
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
74
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
75
|
+
|
|
76
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
|
|
77
|
+
|
|
78
|
+
@client.request(
|
|
79
|
+
method: :get,
|
|
80
|
+
path: path,
|
|
81
|
+
query: query_params,
|
|
82
|
+
headers: headers,
|
|
83
|
+
body: body)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Retrieve the last known commands(s) sent to the device
|
|
87
|
+
#
|
|
88
|
+
# Parameters:
|
|
89
|
+
# * {string} applicationId - ID associated with the application
|
|
90
|
+
# * {string} deviceId - ID associated with the device
|
|
91
|
+
# * {string} limit - Max command entries to return (ordered by time descending)
|
|
92
|
+
# * {string} since - Look for command entries since this time (ms since epoch)
|
|
93
|
+
# * {boolean} _actions - Return resource actions in response
|
|
94
|
+
# * {boolean} _links - Return resource link in response
|
|
95
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
96
|
+
#
|
|
97
|
+
# Responses:
|
|
98
|
+
# * 200 - Recent device commands (https://api.losant.com/#/definitions/deviceCommands)
|
|
99
|
+
#
|
|
100
|
+
# Errors:
|
|
101
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
102
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
103
|
+
def get_command(params = {})
|
|
104
|
+
params = Utils.symbolize_hash_keys(params)
|
|
105
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
106
|
+
headers = {}
|
|
107
|
+
body = nil
|
|
108
|
+
|
|
109
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
110
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
111
|
+
|
|
112
|
+
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
|
113
|
+
query_params[:since] = params[:since] if params.has_key?(:since)
|
|
114
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
115
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
116
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
117
|
+
|
|
118
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command"
|
|
119
|
+
|
|
120
|
+
@client.request(
|
|
121
|
+
method: :get,
|
|
122
|
+
path: path,
|
|
123
|
+
query: query_params,
|
|
124
|
+
headers: headers,
|
|
125
|
+
body: body)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Retrieve the recent log entries about the device
|
|
129
|
+
#
|
|
130
|
+
# Parameters:
|
|
131
|
+
# * {string} applicationId - ID associated with the application
|
|
132
|
+
# * {string} deviceId - ID associated with the device
|
|
133
|
+
# * {string} limit - Max log entries to return (ordered by time descending)
|
|
134
|
+
# * {string} since - Look for log entries since this time (ms since epoch)
|
|
135
|
+
# * {boolean} _actions - Return resource actions in response
|
|
136
|
+
# * {boolean} _links - Return resource link in response
|
|
137
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
138
|
+
#
|
|
139
|
+
# Responses:
|
|
140
|
+
# * 200 - Recent log entries (https://api.losant.com/#/definitions/deviceLog)
|
|
141
|
+
#
|
|
142
|
+
# Errors:
|
|
143
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
144
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
145
|
+
def get_log_entries(params = {})
|
|
146
|
+
params = Utils.symbolize_hash_keys(params)
|
|
147
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
148
|
+
headers = {}
|
|
149
|
+
body = nil
|
|
150
|
+
|
|
151
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
152
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
153
|
+
|
|
154
|
+
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
|
155
|
+
query_params[:since] = params[:since] if params.has_key?(:since)
|
|
156
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
157
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
158
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
159
|
+
|
|
160
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/logs"
|
|
161
|
+
|
|
162
|
+
@client.request(
|
|
163
|
+
method: :get,
|
|
164
|
+
path: path,
|
|
165
|
+
query: query_params,
|
|
166
|
+
headers: headers,
|
|
167
|
+
body: body)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
# Retrieve the last known state(s) of the device
|
|
171
|
+
#
|
|
172
|
+
# Parameters:
|
|
173
|
+
# * {string} applicationId - ID associated with the application
|
|
174
|
+
# * {string} deviceId - ID associated with the device
|
|
175
|
+
# * {string} limit - Max state entries to return (ordered by time descending)
|
|
176
|
+
# * {string} since - Look for state entries since this time (ms since epoch)
|
|
177
|
+
# * {boolean} _actions - Return resource actions in response
|
|
178
|
+
# * {boolean} _links - Return resource link in response
|
|
179
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
180
|
+
#
|
|
181
|
+
# Responses:
|
|
182
|
+
# * 200 - Recent device states (https://api.losant.com/#/definitions/deviceStates)
|
|
183
|
+
#
|
|
184
|
+
# Errors:
|
|
185
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
186
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
187
|
+
def get_state(params = {})
|
|
188
|
+
params = Utils.symbolize_hash_keys(params)
|
|
189
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
190
|
+
headers = {}
|
|
191
|
+
body = nil
|
|
192
|
+
|
|
193
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
194
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
195
|
+
|
|
196
|
+
query_params[:limit] = params[:limit] if params.has_key?(:limit)
|
|
197
|
+
query_params[:since] = params[:since] if params.has_key?(:since)
|
|
198
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
199
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
200
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
201
|
+
|
|
202
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state"
|
|
203
|
+
|
|
204
|
+
@client.request(
|
|
205
|
+
method: :get,
|
|
206
|
+
path: path,
|
|
207
|
+
query: query_params,
|
|
208
|
+
headers: headers,
|
|
209
|
+
body: body)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# Updates information about a device
|
|
213
|
+
#
|
|
214
|
+
# Parameters:
|
|
215
|
+
# * {string} applicationId - ID associated with the application
|
|
216
|
+
# * {string} deviceId - ID associated with the device
|
|
217
|
+
# * {hash} device - Object containing new properties of the device (https://api.losant.com/#/definitions/devicePatch)
|
|
218
|
+
# * {boolean} _actions - Return resource actions in response
|
|
219
|
+
# * {boolean} _links - Return resource link in response
|
|
220
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
221
|
+
#
|
|
222
|
+
# Responses:
|
|
223
|
+
# * 200 - Updated device information (https://api.losant.com/#/definitions/device)
|
|
224
|
+
#
|
|
225
|
+
# Errors:
|
|
226
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
227
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
228
|
+
def patch(params = {})
|
|
229
|
+
params = Utils.symbolize_hash_keys(params)
|
|
230
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
231
|
+
headers = {}
|
|
232
|
+
body = nil
|
|
233
|
+
|
|
234
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
235
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
236
|
+
raise ArgumentError.new("device is required") unless params.has_key?(:device)
|
|
237
|
+
|
|
238
|
+
body = params[:device] if params.has_key?(:device)
|
|
239
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
240
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
241
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
242
|
+
|
|
243
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}"
|
|
244
|
+
|
|
245
|
+
@client.request(
|
|
246
|
+
method: :patch,
|
|
247
|
+
path: path,
|
|
248
|
+
query: query_params,
|
|
249
|
+
headers: headers,
|
|
250
|
+
body: body)
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Send a command to a device
|
|
254
|
+
#
|
|
255
|
+
# Parameters:
|
|
256
|
+
# * {string} applicationId - ID associated with the application
|
|
257
|
+
# * {string} deviceId - ID associated with the device
|
|
258
|
+
# * {hash} deviceCommand - Command to send to the device (https://api.losant.com/#/definitions/deviceCommand)
|
|
259
|
+
# * {boolean} _actions - Return resource actions in response
|
|
260
|
+
# * {boolean} _links - Return resource link in response
|
|
261
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
262
|
+
#
|
|
263
|
+
# Responses:
|
|
264
|
+
# * 200 - If command was successfully sent (https://api.losant.com/#/definitions/success)
|
|
265
|
+
#
|
|
266
|
+
# Errors:
|
|
267
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
268
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
269
|
+
def send_command(params = {})
|
|
270
|
+
params = Utils.symbolize_hash_keys(params)
|
|
271
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
272
|
+
headers = {}
|
|
273
|
+
body = nil
|
|
274
|
+
|
|
275
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
276
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
277
|
+
raise ArgumentError.new("deviceCommand is required") unless params.has_key?(:deviceCommand)
|
|
278
|
+
|
|
279
|
+
body = params[:deviceCommand] if params.has_key?(:deviceCommand)
|
|
280
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
281
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
282
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
283
|
+
|
|
284
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/command"
|
|
285
|
+
|
|
286
|
+
@client.request(
|
|
287
|
+
method: :post,
|
|
288
|
+
path: path,
|
|
289
|
+
query: query_params,
|
|
290
|
+
headers: headers,
|
|
291
|
+
body: body)
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Send the current state of the device
|
|
295
|
+
#
|
|
296
|
+
# Parameters:
|
|
297
|
+
# * {string} applicationId - ID associated with the application
|
|
298
|
+
# * {string} deviceId - ID associated with the device
|
|
299
|
+
# * {hash} deviceState - Object containing the current state of the device (https://api.losant.com/#/definitions/deviceState)
|
|
300
|
+
# * {boolean} _actions - Return resource actions in response
|
|
301
|
+
# * {boolean} _links - Return resource link in response
|
|
302
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
303
|
+
#
|
|
304
|
+
# Responses:
|
|
305
|
+
# * 200 - If state was successfully received (https://api.losant.com/#/definitions/success)
|
|
306
|
+
#
|
|
307
|
+
# Errors:
|
|
308
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
309
|
+
# * 404 - Error if device was not found (https://api.losant.com/#/definitions/error)
|
|
310
|
+
def send_state(params = {})
|
|
311
|
+
params = Utils.symbolize_hash_keys(params)
|
|
312
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
313
|
+
headers = {}
|
|
314
|
+
body = nil
|
|
315
|
+
|
|
316
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
317
|
+
raise ArgumentError.new("deviceId is required") unless params.has_key?(:deviceId)
|
|
318
|
+
raise ArgumentError.new("deviceState is required") unless params.has_key?(:deviceState)
|
|
319
|
+
|
|
320
|
+
body = params[:deviceState] if params.has_key?(:deviceState)
|
|
321
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
322
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
323
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
324
|
+
|
|
325
|
+
path = "/applications/#{params[:applicationId]}/devices/#{params[:deviceId]}/state"
|
|
326
|
+
|
|
327
|
+
@client.request(
|
|
328
|
+
method: :post,
|
|
329
|
+
path: path,
|
|
330
|
+
query: query_params,
|
|
331
|
+
headers: headers,
|
|
332
|
+
body: body)
|
|
333
|
+
end
|
|
334
|
+
|
|
335
|
+
end
|
|
336
|
+
end
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Device Recipe Resource
|
|
4
|
+
class DeviceRecipe
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Bulk creates devices using this recipe from a CSV
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} deviceRecipeId - ID associated with the device recipe
|
|
15
|
+
# * {hash} bulkInfo - Object containing bulk creation info (https://api.losant.com/#/definitions/deviceRecipeBulkCreatePost)
|
|
16
|
+
# * {boolean} _actions - Return resource actions in response
|
|
17
|
+
# * {boolean} _links - Return resource link in response
|
|
18
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
19
|
+
#
|
|
20
|
+
# Responses:
|
|
21
|
+
# * 201 - If devices were sucessfully created (https://api.losant.com/#/definitions/deviceRecipeBulkCreate)
|
|
22
|
+
#
|
|
23
|
+
# Errors:
|
|
24
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
25
|
+
# * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error)
|
|
26
|
+
def bulk_create(params = {})
|
|
27
|
+
params = Utils.symbolize_hash_keys(params)
|
|
28
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
29
|
+
headers = {}
|
|
30
|
+
body = nil
|
|
31
|
+
|
|
32
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
33
|
+
raise ArgumentError.new("deviceRecipeId is required") unless params.has_key?(:deviceRecipeId)
|
|
34
|
+
raise ArgumentError.new("bulkInfo is required") unless params.has_key?(:bulkInfo)
|
|
35
|
+
|
|
36
|
+
body = params[:bulkInfo] if params.has_key?(:bulkInfo)
|
|
37
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
38
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
39
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
40
|
+
|
|
41
|
+
path = "/applications/#{params[:applicationId]}/device-recipes/#{params[:deviceRecipeId]}/bulkCreate"
|
|
42
|
+
|
|
43
|
+
@client.request(
|
|
44
|
+
method: :post,
|
|
45
|
+
path: path,
|
|
46
|
+
query: query_params,
|
|
47
|
+
headers: headers,
|
|
48
|
+
body: body)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Deletes a device recipe
|
|
52
|
+
#
|
|
53
|
+
# Parameters:
|
|
54
|
+
# * {string} applicationId - ID associated with the application
|
|
55
|
+
# * {string} deviceRecipeId - ID associated with the device recipe
|
|
56
|
+
# * {boolean} _actions - Return resource actions in response
|
|
57
|
+
# * {boolean} _links - Return resource link in response
|
|
58
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
59
|
+
#
|
|
60
|
+
# Responses:
|
|
61
|
+
# * 200 - If device recipe was successfully deleted (https://api.losant.com/#/definitions/success)
|
|
62
|
+
#
|
|
63
|
+
# Errors:
|
|
64
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
65
|
+
# * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error)
|
|
66
|
+
def delete(params = {})
|
|
67
|
+
params = Utils.symbolize_hash_keys(params)
|
|
68
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
69
|
+
headers = {}
|
|
70
|
+
body = nil
|
|
71
|
+
|
|
72
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
73
|
+
raise ArgumentError.new("deviceRecipeId is required") unless params.has_key?(:deviceRecipeId)
|
|
74
|
+
|
|
75
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
76
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
77
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
78
|
+
|
|
79
|
+
path = "/applications/#{params[:applicationId]}/device-recipes/#{params[:deviceRecipeId]}"
|
|
80
|
+
|
|
81
|
+
@client.request(
|
|
82
|
+
method: :delete,
|
|
83
|
+
path: path,
|
|
84
|
+
query: query_params,
|
|
85
|
+
headers: headers,
|
|
86
|
+
body: body)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Retrieves information on a device recipe
|
|
90
|
+
#
|
|
91
|
+
# Parameters:
|
|
92
|
+
# * {string} applicationId - ID associated with the application
|
|
93
|
+
# * {string} deviceRecipeId - ID associated with the device recipe
|
|
94
|
+
# * {boolean} _actions - Return resource actions in response
|
|
95
|
+
# * {boolean} _links - Return resource link in response
|
|
96
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
97
|
+
#
|
|
98
|
+
# Responses:
|
|
99
|
+
# * 200 - Device recipe information (https://api.losant.com/#/definitions/deviceRecipe)
|
|
100
|
+
#
|
|
101
|
+
# Errors:
|
|
102
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
103
|
+
# * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error)
|
|
104
|
+
def get(params = {})
|
|
105
|
+
params = Utils.symbolize_hash_keys(params)
|
|
106
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
107
|
+
headers = {}
|
|
108
|
+
body = nil
|
|
109
|
+
|
|
110
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
111
|
+
raise ArgumentError.new("deviceRecipeId is required") unless params.has_key?(:deviceRecipeId)
|
|
112
|
+
|
|
113
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
114
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
115
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
116
|
+
|
|
117
|
+
path = "/applications/#{params[:applicationId]}/device-recipes/#{params[:deviceRecipeId]}"
|
|
118
|
+
|
|
119
|
+
@client.request(
|
|
120
|
+
method: :get,
|
|
121
|
+
path: path,
|
|
122
|
+
query: query_params,
|
|
123
|
+
headers: headers,
|
|
124
|
+
body: body)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Updates information about a device recipe
|
|
128
|
+
#
|
|
129
|
+
# Parameters:
|
|
130
|
+
# * {string} applicationId - ID associated with the application
|
|
131
|
+
# * {string} deviceRecipeId - ID associated with the device recipe
|
|
132
|
+
# * {hash} deviceRecipe - Object containing new properties of the device recipe (https://api.losant.com/#/definitions/deviceRecipePatch)
|
|
133
|
+
# * {boolean} _actions - Return resource actions in response
|
|
134
|
+
# * {boolean} _links - Return resource link in response
|
|
135
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
136
|
+
#
|
|
137
|
+
# Responses:
|
|
138
|
+
# * 200 - Updated device recipe information (https://api.losant.com/#/definitions/deviceRecipe)
|
|
139
|
+
#
|
|
140
|
+
# Errors:
|
|
141
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
142
|
+
# * 404 - Error if device recipe was not found (https://api.losant.com/#/definitions/error)
|
|
143
|
+
def patch(params = {})
|
|
144
|
+
params = Utils.symbolize_hash_keys(params)
|
|
145
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
146
|
+
headers = {}
|
|
147
|
+
body = nil
|
|
148
|
+
|
|
149
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
150
|
+
raise ArgumentError.new("deviceRecipeId is required") unless params.has_key?(:deviceRecipeId)
|
|
151
|
+
raise ArgumentError.new("deviceRecipe is required") unless params.has_key?(:deviceRecipe)
|
|
152
|
+
|
|
153
|
+
body = params[:deviceRecipe] if params.has_key?(:deviceRecipe)
|
|
154
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
155
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
156
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
157
|
+
|
|
158
|
+
path = "/applications/#{params[:applicationId]}/device-recipes/#{params[:deviceRecipeId]}"
|
|
159
|
+
|
|
160
|
+
@client.request(
|
|
161
|
+
method: :patch,
|
|
162
|
+
path: path,
|
|
163
|
+
query: query_params,
|
|
164
|
+
headers: headers,
|
|
165
|
+
body: body)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
end
|
|
169
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Device Recipes Resource
|
|
4
|
+
class DeviceRecipes
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the device recipes for an application
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} sortField - Field to sort the results by. Accepted values are: name, id, creationDate
|
|
15
|
+
# * {string} sortDirection - Direction to sort the results by. Accepted values are: asc, desc
|
|
16
|
+
# * {string} page - Which page of results to return
|
|
17
|
+
# * {string} perPage - How many items to return per page
|
|
18
|
+
# * {string} filterField - Field to filter the results by. Blank or not provided means no filtering. Accepted values are: name
|
|
19
|
+
# * {string} filter - Filter to apply against the filtered field. Supports globbing. Blank or not provided means no filtering.
|
|
20
|
+
# * {boolean} _actions - Return resource actions in response
|
|
21
|
+
# * {boolean} _links - Return resource link in response
|
|
22
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
23
|
+
#
|
|
24
|
+
# Responses:
|
|
25
|
+
# * 200 - Collection of device recipes (https://api.losant.com/#/definitions/deviceRecipes)
|
|
26
|
+
#
|
|
27
|
+
# Errors:
|
|
28
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
29
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
30
|
+
def get(params = {})
|
|
31
|
+
params = Utils.symbolize_hash_keys(params)
|
|
32
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
33
|
+
headers = {}
|
|
34
|
+
body = nil
|
|
35
|
+
|
|
36
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
37
|
+
|
|
38
|
+
query_params[:sortField] = params[:sortField] if params.has_key?(:sortField)
|
|
39
|
+
query_params[:sortDirection] = params[:sortDirection] if params.has_key?(:sortDirection)
|
|
40
|
+
query_params[:page] = params[:page] if params.has_key?(:page)
|
|
41
|
+
query_params[:perPage] = params[:perPage] if params.has_key?(:perPage)
|
|
42
|
+
query_params[:filterField] = params[:filterField] if params.has_key?(:filterField)
|
|
43
|
+
query_params[:filter] = params[:filter] if params.has_key?(:filter)
|
|
44
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
45
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
46
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
47
|
+
|
|
48
|
+
path = "/applications/#{params[:applicationId]}/device-recipes"
|
|
49
|
+
|
|
50
|
+
@client.request(
|
|
51
|
+
method: :get,
|
|
52
|
+
path: path,
|
|
53
|
+
query: query_params,
|
|
54
|
+
headers: headers,
|
|
55
|
+
body: body)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Create a new device recipe for an application
|
|
59
|
+
#
|
|
60
|
+
# Parameters:
|
|
61
|
+
# * {string} applicationId - ID associated with the application
|
|
62
|
+
# * {hash} deviceRecipe - New device recipe information (https://api.losant.com/#/definitions/deviceRecipePost)
|
|
63
|
+
# * {boolean} _actions - Return resource actions in response
|
|
64
|
+
# * {boolean} _links - Return resource link in response
|
|
65
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
66
|
+
#
|
|
67
|
+
# Responses:
|
|
68
|
+
# * 201 - Successfully created device recipe (https://api.losant.com/#/definitions/deviceRecipe)
|
|
69
|
+
#
|
|
70
|
+
# Errors:
|
|
71
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
72
|
+
# * 404 - Error if application was not found (https://api.losant.com/#/definitions/error)
|
|
73
|
+
def post(params = {})
|
|
74
|
+
params = Utils.symbolize_hash_keys(params)
|
|
75
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
76
|
+
headers = {}
|
|
77
|
+
body = nil
|
|
78
|
+
|
|
79
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
80
|
+
raise ArgumentError.new("deviceRecipe is required") unless params.has_key?(:deviceRecipe)
|
|
81
|
+
|
|
82
|
+
body = params[:deviceRecipe] if params.has_key?(:deviceRecipe)
|
|
83
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
84
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
85
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
86
|
+
|
|
87
|
+
path = "/applications/#{params[:applicationId]}/device-recipes"
|
|
88
|
+
|
|
89
|
+
@client.request(
|
|
90
|
+
method: :post,
|
|
91
|
+
path: path,
|
|
92
|
+
query: query_params,
|
|
93
|
+
headers: headers,
|
|
94
|
+
body: body)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
end
|