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,290 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Flow Resource
|
|
4
|
+
class Flow
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Deletes a flow
|
|
11
|
+
#
|
|
12
|
+
# Parameters:
|
|
13
|
+
# * {string} applicationId - ID associated with the application
|
|
14
|
+
# * {string} flowId - ID associated with the flow
|
|
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 flow 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 flow 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("flowId is required") unless params.has_key?(:flowId)
|
|
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]}/flows/#{params[:flowId]}"
|
|
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 flow
|
|
49
|
+
#
|
|
50
|
+
# Parameters:
|
|
51
|
+
# * {string} applicationId - ID associated with the application
|
|
52
|
+
# * {string} flowId - ID associated with the flow
|
|
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 - Flow information (https://api.losant.com/#/definitions/flow)
|
|
59
|
+
#
|
|
60
|
+
# Errors:
|
|
61
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
62
|
+
# * 404 - Error if flow 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("flowId is required") unless params.has_key?(:flowId)
|
|
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]}/flows/#{params[:flowId]}"
|
|
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 recent log entries about the flows
|
|
87
|
+
#
|
|
88
|
+
# Parameters:
|
|
89
|
+
# * {string} applicationId - ID associated with the application
|
|
90
|
+
# * {string} flowId - ID associated with the flow
|
|
91
|
+
# * {string} limit - Max log entries to return (ordered by time descending)
|
|
92
|
+
# * {string} since - Look for log 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 log entries (https://api.losant.com/#/definitions/flowLog)
|
|
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_log_entries(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("flowId is required") unless params.has_key?(:flowId)
|
|
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]}/flows/#{params[:flowId]}/logs"
|
|
119
|
+
|
|
120
|
+
@client.request(
|
|
121
|
+
method: :get,
|
|
122
|
+
path: path,
|
|
123
|
+
query: query_params,
|
|
124
|
+
headers: headers,
|
|
125
|
+
body: body)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Gets the current values in persistent storage
|
|
129
|
+
#
|
|
130
|
+
# Parameters:
|
|
131
|
+
# * {string} applicationId - ID associated with the application
|
|
132
|
+
# * {string} flowId - ID associated with the flow
|
|
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 - The stored values (https://api.losant.com/#/definitions/flowStorageEntries)
|
|
139
|
+
#
|
|
140
|
+
# Errors:
|
|
141
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
142
|
+
# * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
|
|
143
|
+
def get_storage_entries(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("flowId is required") unless params.has_key?(:flowId)
|
|
151
|
+
|
|
152
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
153
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
154
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
155
|
+
|
|
156
|
+
path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/storage"
|
|
157
|
+
|
|
158
|
+
@client.request(
|
|
159
|
+
method: :get,
|
|
160
|
+
path: path,
|
|
161
|
+
query: query_params,
|
|
162
|
+
headers: headers,
|
|
163
|
+
body: body)
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Updates information about a flow
|
|
167
|
+
#
|
|
168
|
+
# Parameters:
|
|
169
|
+
# * {string} applicationId - ID associated with the application
|
|
170
|
+
# * {string} flowId - ID associated with the flow
|
|
171
|
+
# * {hash} flow - Object containing new properties of the flow (https://api.losant.com/#/definitions/flowPatch)
|
|
172
|
+
# * {boolean} _actions - Return resource actions in response
|
|
173
|
+
# * {boolean} _links - Return resource link in response
|
|
174
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
175
|
+
#
|
|
176
|
+
# Responses:
|
|
177
|
+
# * 200 - Updated flow information (https://api.losant.com/#/definitions/flow)
|
|
178
|
+
#
|
|
179
|
+
# Errors:
|
|
180
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
181
|
+
# * 404 - Error if flow is not found (https://api.losant.com/#/definitions/error)
|
|
182
|
+
def patch(params = {})
|
|
183
|
+
params = Utils.symbolize_hash_keys(params)
|
|
184
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
185
|
+
headers = {}
|
|
186
|
+
body = nil
|
|
187
|
+
|
|
188
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
189
|
+
raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
|
|
190
|
+
raise ArgumentError.new("flow is required") unless params.has_key?(:flow)
|
|
191
|
+
|
|
192
|
+
body = params[:flow] if params.has_key?(:flow)
|
|
193
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
194
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
195
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
196
|
+
|
|
197
|
+
path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}"
|
|
198
|
+
|
|
199
|
+
@client.request(
|
|
200
|
+
method: :patch,
|
|
201
|
+
path: path,
|
|
202
|
+
query: query_params,
|
|
203
|
+
headers: headers,
|
|
204
|
+
body: body)
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
# Presses the specified virtual button on the flow
|
|
208
|
+
#
|
|
209
|
+
# Parameters:
|
|
210
|
+
# * {string} applicationId - ID associated with the application
|
|
211
|
+
# * {string} flowId - ID associated with the flow
|
|
212
|
+
# * {hash} button - Object containing button key and payload (https://api.losant.com/#/definitions/virtualButtonPress)
|
|
213
|
+
# * {boolean} _actions - Return resource actions in response
|
|
214
|
+
# * {boolean} _links - Return resource link in response
|
|
215
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
216
|
+
#
|
|
217
|
+
# Responses:
|
|
218
|
+
# * 200 - Virtual button was pressed (https://api.losant.com/#/definitions/success)
|
|
219
|
+
#
|
|
220
|
+
# Errors:
|
|
221
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
222
|
+
# * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
|
|
223
|
+
def press_virtual_button(params = {})
|
|
224
|
+
params = Utils.symbolize_hash_keys(params)
|
|
225
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
226
|
+
headers = {}
|
|
227
|
+
body = nil
|
|
228
|
+
|
|
229
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
230
|
+
raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
|
|
231
|
+
raise ArgumentError.new("button is required") unless params.has_key?(:button)
|
|
232
|
+
|
|
233
|
+
body = params[:button] if params.has_key?(:button)
|
|
234
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
235
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
236
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
237
|
+
|
|
238
|
+
path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/virtualButton"
|
|
239
|
+
|
|
240
|
+
@client.request(
|
|
241
|
+
method: :post,
|
|
242
|
+
path: path,
|
|
243
|
+
query: query_params,
|
|
244
|
+
headers: headers,
|
|
245
|
+
body: body)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
# Sets a storage value
|
|
249
|
+
#
|
|
250
|
+
# Parameters:
|
|
251
|
+
# * {string} applicationId - ID associated with the application
|
|
252
|
+
# * {string} flowId - ID associated with the flow
|
|
253
|
+
# * {hash} entry - Object containing storage entry (https://api.losant.com/#/definitions/flowStorageEntry)
|
|
254
|
+
# * {boolean} _actions - Return resource actions in response
|
|
255
|
+
# * {boolean} _links - Return resource link in response
|
|
256
|
+
# * {boolean} _embedded - Return embedded resources in response
|
|
257
|
+
#
|
|
258
|
+
# Responses:
|
|
259
|
+
# * 200 - Value was successfully stored (https://api.losant.com/#/definitions/success)
|
|
260
|
+
#
|
|
261
|
+
# Errors:
|
|
262
|
+
# * 400 - Error if malformed request (https://api.losant.com/#/definitions/error)
|
|
263
|
+
# * 404 - Error if flow was not found (https://api.losant.com/#/definitions/error)
|
|
264
|
+
def set_storage_entry(params = {})
|
|
265
|
+
params = Utils.symbolize_hash_keys(params)
|
|
266
|
+
query_params = { _actions: false, _links: true, _embedded: true }
|
|
267
|
+
headers = {}
|
|
268
|
+
body = nil
|
|
269
|
+
|
|
270
|
+
raise ArgumentError.new("applicationId is required") unless params.has_key?(:applicationId)
|
|
271
|
+
raise ArgumentError.new("flowId is required") unless params.has_key?(:flowId)
|
|
272
|
+
raise ArgumentError.new("entry is required") unless params.has_key?(:entry)
|
|
273
|
+
|
|
274
|
+
body = params[:entry] if params.has_key?(:entry)
|
|
275
|
+
query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
|
|
276
|
+
query_params[:_links] = params[:_links] if params.has_key?(:_links)
|
|
277
|
+
query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)
|
|
278
|
+
|
|
279
|
+
path = "/applications/#{params[:applicationId]}/flows/#{params[:flowId]}/storage"
|
|
280
|
+
|
|
281
|
+
@client.request(
|
|
282
|
+
method: :patch,
|
|
283
|
+
path: path,
|
|
284
|
+
query: query_params,
|
|
285
|
+
headers: headers,
|
|
286
|
+
body: body)
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
end
|
|
290
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
module LosantRest
|
|
2
|
+
|
|
3
|
+
# Class containing all the actions for the Flows Resource
|
|
4
|
+
class Flows
|
|
5
|
+
|
|
6
|
+
def initialize(client)
|
|
7
|
+
@client = client
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns the flows 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 flows (https://api.losant.com/#/definitions/flows)
|
|
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]}/flows"
|
|
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 flow for an application
|
|
59
|
+
#
|
|
60
|
+
# Parameters:
|
|
61
|
+
# * {string} applicationId - ID associated with the application
|
|
62
|
+
# * {hash} flow - New flow information (https://api.losant.com/#/definitions/flowPost)
|
|
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 flow (https://api.losant.com/#/definitions/flow)
|
|
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("flow is required") unless params.has_key?(:flow)
|
|
81
|
+
|
|
82
|
+
body = params[:flow] if params.has_key?(:flow)
|
|
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]}/flows"
|
|
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
|