Class: LosantRest::Client
- Inherits:
-
Object
- Object
- LosantRest::Client
- Defined in:
- lib/losant_rest/client.rb
Overview
Losant API
User API for accessing Losant data
Built For Version 1.24.1
Instance Attribute Summary collapse
-
#auth_token ⇒ Object
Returns the value of attribute auth_token.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #application ⇒ Object
- #application_api_token ⇒ Object
- #application_api_tokens ⇒ Object
- #application_certificate ⇒ Object
- #application_certificate_authorities ⇒ Object
- #application_certificate_authority ⇒ Object
- #application_certificates ⇒ Object
- #application_dashboard ⇒ Object
- #application_dashboards ⇒ Object
- #application_key ⇒ Object
- #application_keys ⇒ Object
- #application_template ⇒ Object
- #application_templates ⇒ Object
- #applications ⇒ Object
- #audit_log ⇒ Object
- #audit_logs ⇒ Object
- #auth ⇒ Object
- #dashboard ⇒ Object
- #dashboards ⇒ Object
- #data ⇒ Object
- #data_table ⇒ Object
- #data_table_row ⇒ Object
- #data_table_rows ⇒ Object
- #data_tables ⇒ Object
- #device ⇒ Object
- #device_recipe ⇒ Object
- #device_recipes ⇒ Object
- #devices ⇒ Object
- #edge_deployment ⇒ Object
- #edge_deployments ⇒ Object
- #embedded_deployment ⇒ Object
- #embedded_deployments ⇒ Object
- #event ⇒ Object
- #events ⇒ Object
- #experience ⇒ Object
- #experience_domain ⇒ Object
- #experience_domains ⇒ Object
- #experience_endpoint ⇒ Object
- #experience_endpoints ⇒ Object
- #experience_group ⇒ Object
- #experience_groups ⇒ Object
- #experience_slug ⇒ Object
- #experience_slugs ⇒ Object
- #experience_user ⇒ Object
- #experience_users ⇒ Object
- #experience_version ⇒ Object
- #experience_versions ⇒ Object
- #experience_view ⇒ Object
- #experience_views ⇒ Object
- #file ⇒ Object
- #files ⇒ Object
- #flow ⇒ Object
- #flow_version ⇒ Object
- #flow_versions ⇒ Object
- #flows ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #instance ⇒ Object
- #instance_api_token ⇒ Object
- #instance_api_tokens ⇒ Object
- #instance_custom_node ⇒ Object
- #instance_custom_nodes ⇒ Object
- #instance_member ⇒ Object
- #instance_members ⇒ Object
- #instance_org ⇒ Object
- #instance_org_invite ⇒ Object
- #instance_org_invites ⇒ Object
- #instance_org_member ⇒ Object
- #instance_org_members ⇒ Object
- #instance_orgs ⇒ Object
- #instance_sandbox ⇒ Object
- #instance_sandboxes ⇒ Object
- #instances ⇒ Object
- #integration ⇒ Object
- #integrations ⇒ Object
- #me ⇒ Object
- #notebook ⇒ Object
- #notebooks ⇒ Object
- #org ⇒ Object
- #org_invites ⇒ Object
- #orgs ⇒ Object
- #request(options = {}) ⇒ Object
- #resource_job ⇒ Object
- #resource_jobs ⇒ Object
- #user_api_token ⇒ Object
- #user_api_tokens ⇒ Object
- #webhook ⇒ Object
- #webhooks ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
34 35 36 37 |
# File 'lib/losant_rest/client.rb', line 34 def initialize( = {}) self.auth_token = .fetch(:auth_token, nil) self.url = .fetch(:url, "https://api.losant.com") end |
Instance Attribute Details
#auth_token ⇒ Object
Returns the value of attribute auth_token.
32 33 34 |
# File 'lib/losant_rest/client.rb', line 32 def auth_token @auth_token end |
#url ⇒ Object
Returns the value of attribute url.
32 33 34 |
# File 'lib/losant_rest/client.rb', line 32 def url @url end |
Instance Method Details
#application ⇒ Object
39 40 41 |
# File 'lib/losant_rest/client.rb', line 39 def application @application ||= Application.new(self) end |
#application_api_token ⇒ Object
43 44 45 |
# File 'lib/losant_rest/client.rb', line 43 def application_api_token @application_api_token ||= ApplicationApiToken.new(self) end |
#application_api_tokens ⇒ Object
47 48 49 |
# File 'lib/losant_rest/client.rb', line 47 def application_api_tokens @application_api_tokens ||= ApplicationApiTokens.new(self) end |
#application_certificate ⇒ Object
51 52 53 |
# File 'lib/losant_rest/client.rb', line 51 def application_certificate @application_certificate ||= ApplicationCertificate.new(self) end |
#application_certificate_authorities ⇒ Object
55 56 57 |
# File 'lib/losant_rest/client.rb', line 55 def @application_certificate_authorities ||= ApplicationCertificateAuthorities.new(self) end |
#application_certificate_authority ⇒ Object
59 60 61 |
# File 'lib/losant_rest/client.rb', line 59 def @application_certificate_authority ||= ApplicationCertificateAuthority.new(self) end |
#application_certificates ⇒ Object
63 64 65 |
# File 'lib/losant_rest/client.rb', line 63 def application_certificates @application_certificates ||= ApplicationCertificates.new(self) end |
#application_dashboard ⇒ Object
67 68 69 |
# File 'lib/losant_rest/client.rb', line 67 def application_dashboard @application_dashboard ||= ApplicationDashboard.new(self) end |
#application_dashboards ⇒ Object
71 72 73 |
# File 'lib/losant_rest/client.rb', line 71 def application_dashboards @application_dashboards ||= ApplicationDashboards.new(self) end |
#application_key ⇒ Object
75 76 77 |
# File 'lib/losant_rest/client.rb', line 75 def application_key @application_key ||= ApplicationKey.new(self) end |
#application_keys ⇒ Object
79 80 81 |
# File 'lib/losant_rest/client.rb', line 79 def application_keys @application_keys ||= ApplicationKeys.new(self) end |
#application_template ⇒ Object
83 84 85 |
# File 'lib/losant_rest/client.rb', line 83 def application_template @application_template ||= ApplicationTemplate.new(self) end |
#application_templates ⇒ Object
87 88 89 |
# File 'lib/losant_rest/client.rb', line 87 def application_templates @application_templates ||= ApplicationTemplates.new(self) end |
#applications ⇒ Object
91 92 93 |
# File 'lib/losant_rest/client.rb', line 91 def applications @applications ||= Applications.new(self) end |
#audit_log ⇒ Object
95 96 97 |
# File 'lib/losant_rest/client.rb', line 95 def audit_log @audit_log ||= AuditLog.new(self) end |
#audit_logs ⇒ Object
99 100 101 |
# File 'lib/losant_rest/client.rb', line 99 def audit_logs @audit_logs ||= AuditLogs.new(self) end |
#auth ⇒ Object
103 104 105 |
# File 'lib/losant_rest/client.rb', line 103 def auth @auth ||= Auth.new(self) end |
#dashboard ⇒ Object
107 108 109 |
# File 'lib/losant_rest/client.rb', line 107 def dashboard @dashboard ||= Dashboard.new(self) end |
#dashboards ⇒ Object
111 112 113 |
# File 'lib/losant_rest/client.rb', line 111 def dashboards @dashboards ||= Dashboards.new(self) end |
#data ⇒ Object
115 116 117 |
# File 'lib/losant_rest/client.rb', line 115 def data @data ||= Data.new(self) end |
#data_table ⇒ Object
119 120 121 |
# File 'lib/losant_rest/client.rb', line 119 def data_table @data_table ||= DataTable.new(self) end |
#data_table_row ⇒ Object
123 124 125 |
# File 'lib/losant_rest/client.rb', line 123 def data_table_row @data_table_row ||= DataTableRow.new(self) end |
#data_table_rows ⇒ Object
127 128 129 |
# File 'lib/losant_rest/client.rb', line 127 def data_table_rows @data_table_rows ||= DataTableRows.new(self) end |
#data_tables ⇒ Object
131 132 133 |
# File 'lib/losant_rest/client.rb', line 131 def data_tables @data_tables ||= DataTables.new(self) end |
#device ⇒ Object
135 136 137 |
# File 'lib/losant_rest/client.rb', line 135 def device @device ||= Device.new(self) end |
#device_recipe ⇒ Object
139 140 141 |
# File 'lib/losant_rest/client.rb', line 139 def device_recipe @device_recipe ||= DeviceRecipe.new(self) end |
#device_recipes ⇒ Object
143 144 145 |
# File 'lib/losant_rest/client.rb', line 143 def device_recipes @device_recipes ||= DeviceRecipes.new(self) end |
#devices ⇒ Object
147 148 149 |
# File 'lib/losant_rest/client.rb', line 147 def devices @devices ||= Devices.new(self) end |
#edge_deployment ⇒ Object
151 152 153 |
# File 'lib/losant_rest/client.rb', line 151 def edge_deployment @edge_deployment ||= EdgeDeployment.new(self) end |
#edge_deployments ⇒ Object
155 156 157 |
# File 'lib/losant_rest/client.rb', line 155 def edge_deployments @edge_deployments ||= EdgeDeployments.new(self) end |
#embedded_deployment ⇒ Object
159 160 161 |
# File 'lib/losant_rest/client.rb', line 159 def @embedded_deployment ||= EmbeddedDeployment.new(self) end |
#embedded_deployments ⇒ Object
163 164 165 |
# File 'lib/losant_rest/client.rb', line 163 def @embedded_deployments ||= EmbeddedDeployments.new(self) end |
#event ⇒ Object
167 168 169 |
# File 'lib/losant_rest/client.rb', line 167 def event @event ||= Event.new(self) end |
#events ⇒ Object
171 172 173 |
# File 'lib/losant_rest/client.rb', line 171 def events @events ||= Events.new(self) end |
#experience ⇒ Object
175 176 177 |
# File 'lib/losant_rest/client.rb', line 175 def experience @experience ||= Experience.new(self) end |
#experience_domain ⇒ Object
179 180 181 |
# File 'lib/losant_rest/client.rb', line 179 def experience_domain @experience_domain ||= ExperienceDomain.new(self) end |
#experience_domains ⇒ Object
183 184 185 |
# File 'lib/losant_rest/client.rb', line 183 def experience_domains @experience_domains ||= ExperienceDomains.new(self) end |
#experience_endpoint ⇒ Object
187 188 189 |
# File 'lib/losant_rest/client.rb', line 187 def experience_endpoint @experience_endpoint ||= ExperienceEndpoint.new(self) end |
#experience_endpoints ⇒ Object
191 192 193 |
# File 'lib/losant_rest/client.rb', line 191 def experience_endpoints @experience_endpoints ||= ExperienceEndpoints.new(self) end |
#experience_group ⇒ Object
195 196 197 |
# File 'lib/losant_rest/client.rb', line 195 def experience_group @experience_group ||= ExperienceGroup.new(self) end |
#experience_groups ⇒ Object
199 200 201 |
# File 'lib/losant_rest/client.rb', line 199 def experience_groups @experience_groups ||= ExperienceGroups.new(self) end |
#experience_slug ⇒ Object
203 204 205 |
# File 'lib/losant_rest/client.rb', line 203 def experience_slug @experience_slug ||= ExperienceSlug.new(self) end |
#experience_slugs ⇒ Object
207 208 209 |
# File 'lib/losant_rest/client.rb', line 207 def experience_slugs @experience_slugs ||= ExperienceSlugs.new(self) end |
#experience_user ⇒ Object
211 212 213 |
# File 'lib/losant_rest/client.rb', line 211 def experience_user @experience_user ||= ExperienceUser.new(self) end |
#experience_users ⇒ Object
215 216 217 |
# File 'lib/losant_rest/client.rb', line 215 def experience_users @experience_users ||= ExperienceUsers.new(self) end |
#experience_version ⇒ Object
219 220 221 |
# File 'lib/losant_rest/client.rb', line 219 def experience_version @experience_version ||= ExperienceVersion.new(self) end |
#experience_versions ⇒ Object
223 224 225 |
# File 'lib/losant_rest/client.rb', line 223 def experience_versions @experience_versions ||= ExperienceVersions.new(self) end |
#experience_view ⇒ Object
227 228 229 |
# File 'lib/losant_rest/client.rb', line 227 def experience_view @experience_view ||= ExperienceView.new(self) end |
#experience_views ⇒ Object
231 232 233 |
# File 'lib/losant_rest/client.rb', line 231 def experience_views @experience_views ||= ExperienceViews.new(self) end |
#file ⇒ Object
235 236 237 |
# File 'lib/losant_rest/client.rb', line 235 def file @file ||= File.new(self) end |
#files ⇒ Object
239 240 241 |
# File 'lib/losant_rest/client.rb', line 239 def files @files ||= Files.new(self) end |
#flow ⇒ Object
243 244 245 |
# File 'lib/losant_rest/client.rb', line 243 def flow @flow ||= Flow.new(self) end |
#flow_version ⇒ Object
247 248 249 |
# File 'lib/losant_rest/client.rb', line 247 def flow_version @flow_version ||= FlowVersion.new(self) end |
#flow_versions ⇒ Object
251 252 253 |
# File 'lib/losant_rest/client.rb', line 251 def flow_versions @flow_versions ||= FlowVersions.new(self) end |
#flows ⇒ Object
255 256 257 |
# File 'lib/losant_rest/client.rb', line 255 def flows @flows ||= Flows.new(self) end |
#instance ⇒ Object
259 260 261 |
# File 'lib/losant_rest/client.rb', line 259 def instance @instance ||= Instance.new(self) end |
#instance_api_token ⇒ Object
263 264 265 |
# File 'lib/losant_rest/client.rb', line 263 def instance_api_token @instance_api_token ||= InstanceApiToken.new(self) end |
#instance_api_tokens ⇒ Object
267 268 269 |
# File 'lib/losant_rest/client.rb', line 267 def instance_api_tokens @instance_api_tokens ||= InstanceApiTokens.new(self) end |
#instance_custom_node ⇒ Object
271 272 273 |
# File 'lib/losant_rest/client.rb', line 271 def instance_custom_node @instance_custom_node ||= InstanceCustomNode.new(self) end |
#instance_custom_nodes ⇒ Object
275 276 277 |
# File 'lib/losant_rest/client.rb', line 275 def instance_custom_nodes @instance_custom_nodes ||= InstanceCustomNodes.new(self) end |
#instance_member ⇒ Object
279 280 281 |
# File 'lib/losant_rest/client.rb', line 279 def instance_member @instance_member ||= InstanceMember.new(self) end |
#instance_members ⇒ Object
283 284 285 |
# File 'lib/losant_rest/client.rb', line 283 def instance_members @instance_members ||= InstanceMembers.new(self) end |
#instance_org ⇒ Object
287 288 289 |
# File 'lib/losant_rest/client.rb', line 287 def instance_org @instance_org ||= InstanceOrg.new(self) end |
#instance_org_invite ⇒ Object
291 292 293 |
# File 'lib/losant_rest/client.rb', line 291 def instance_org_invite @instance_org_invite ||= InstanceOrgInvite.new(self) end |
#instance_org_invites ⇒ Object
295 296 297 |
# File 'lib/losant_rest/client.rb', line 295 def instance_org_invites @instance_org_invites ||= InstanceOrgInvites.new(self) end |
#instance_org_member ⇒ Object
299 300 301 |
# File 'lib/losant_rest/client.rb', line 299 def instance_org_member @instance_org_member ||= InstanceOrgMember.new(self) end |
#instance_org_members ⇒ Object
303 304 305 |
# File 'lib/losant_rest/client.rb', line 303 def instance_org_members @instance_org_members ||= InstanceOrgMembers.new(self) end |
#instance_orgs ⇒ Object
307 308 309 |
# File 'lib/losant_rest/client.rb', line 307 def instance_orgs @instance_orgs ||= InstanceOrgs.new(self) end |
#instance_sandbox ⇒ Object
311 312 313 |
# File 'lib/losant_rest/client.rb', line 311 def instance_sandbox @instance_sandbox ||= InstanceSandbox.new(self) end |
#instance_sandboxes ⇒ Object
315 316 317 |
# File 'lib/losant_rest/client.rb', line 315 def instance_sandboxes @instance_sandboxes ||= InstanceSandboxes.new(self) end |
#instances ⇒ Object
319 320 321 |
# File 'lib/losant_rest/client.rb', line 319 def instances @instances ||= Instances.new(self) end |
#integration ⇒ Object
323 324 325 |
# File 'lib/losant_rest/client.rb', line 323 def integration @integration ||= Integration.new(self) end |
#integrations ⇒ Object
327 328 329 |
# File 'lib/losant_rest/client.rb', line 327 def integrations @integrations ||= Integrations.new(self) end |
#me ⇒ Object
331 332 333 |
# File 'lib/losant_rest/client.rb', line 331 def me @me ||= Me.new(self) end |
#notebook ⇒ Object
335 336 337 |
# File 'lib/losant_rest/client.rb', line 335 def notebook @notebook ||= Notebook.new(self) end |
#notebooks ⇒ Object
339 340 341 |
# File 'lib/losant_rest/client.rb', line 339 def notebooks @notebooks ||= Notebooks.new(self) end |
#org ⇒ Object
343 344 345 |
# File 'lib/losant_rest/client.rb', line 343 def org @org ||= Org.new(self) end |
#org_invites ⇒ Object
347 348 349 |
# File 'lib/losant_rest/client.rb', line 347 def org_invites @org_invites ||= OrgInvites.new(self) end |
#orgs ⇒ Object
351 352 353 |
# File 'lib/losant_rest/client.rb', line 351 def orgs @orgs ||= Orgs.new(self) end |
#request(options = {}) ⇒ Object
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 |
# File 'lib/losant_rest/client.rb', line 379 def request( = {}) headers = .fetch(:headers, {}) method = .fetch(:method, :get) headers["Accept"] = "application/json" headers["Content-Type"] = "application/json" headers["Accept-Version"] = "^1.24.1" headers["Authorization"] = "Bearer #{self.auth_token}" if self.auth_token path = self.url + .fetch(:path, "") response = HTTParty.send(method, path, query: Utils.fix_query_arrays([:query]), body: [:body] && [:body].to_json(), headers: headers) result = response.parsed_response if response.code >= 400 raise ResponseError.new(response.code, result) end result end |
#resource_job ⇒ Object
355 356 357 |
# File 'lib/losant_rest/client.rb', line 355 def resource_job @resource_job ||= ResourceJob.new(self) end |
#resource_jobs ⇒ Object
359 360 361 |
# File 'lib/losant_rest/client.rb', line 359 def resource_jobs @resource_jobs ||= ResourceJobs.new(self) end |
#user_api_token ⇒ Object
363 364 365 |
# File 'lib/losant_rest/client.rb', line 363 def user_api_token @user_api_token ||= UserApiToken.new(self) end |
#user_api_tokens ⇒ Object
367 368 369 |
# File 'lib/losant_rest/client.rb', line 367 def user_api_tokens @user_api_tokens ||= UserApiTokens.new(self) end |