Class: LosantRest::Org

Inherits:
Object
  • Object
show all
Defined in:
lib/losant_rest/org.rb

Overview

Class containing all the actions for the Org Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Org

Returns a new instance of Org.



30
31
32
# File 'lib/losant_rest/org.rb', line 30

def initialize(client)
  @client = client
end

Instance Method Details

#delete(params = {}) ⇒ Object

Deletes an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.delete.

Parameters:

  • string orgId - ID associated with the organization

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/losant_rest/org.rb', line 55

def delete(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#get(params = {}) ⇒ Object

Retrieves information on an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.get.

Parameters:

  • string orgId - ID associated with the organization

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/losant_rest/org.rb', line 101

def get(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#invite_member(params = {}) ⇒ Object

Invites a person to an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.inviteMember.

Parameters:

  • string orgId - ID associated with the organization

  • hash invite - Object containing new invite info (api.losant.com/#/definitions/orgInvitePost)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/losant_rest/org.rb', line 148

def invite_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("invite is required") unless params.has_key?(:invite)

  body = params[:invite] if params.has_key?(:invite)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :post,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#modify_member(params = {}) ⇒ Object

Modifies a current org member's role

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.modifyMember.

Parameters:

  • string orgId - ID associated with the organization

  • hash member - Object containing new member pair (api.losant.com/#/definitions/orgMemberPatch)

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
# File 'lib/losant_rest/org.rb', line 197

def modify_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("member is required") unless params.has_key?(:member)

  body = params[:member] if params.has_key?(:member)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/member"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#patch(params = {}) ⇒ Object

Updates information about an organization

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.patch.

Parameters:

  • string orgId - ID associated with the organization

  • hash organization - Object containing new organization properties (api.losant.com/#/definitions/orgPatch)

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# File 'lib/losant_rest/org.rb', line 248

def patch(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("organization is required") unless params.has_key?(:organization)

  body = params[:organization] if params.has_key?(:organization)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#payload_counts(params = {}) ⇒ Object

Returns payload counts for the time range specified for all applications this organization owns

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.payloadCounts.

Parameters:

  • string orgId - ID associated with the organization

  • string start - Start of range for payload count query (ms since epoch)

  • string end - End of range for payload count query (ms since epoch)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
# File 'lib/losant_rest/org.rb', line 298

def payload_counts(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  query_params[:start] = params[:start] if params.has_key?(:start)
  query_params[:end] = params[:end] if params.has_key?(:end)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/payloadCounts"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#pending_invites(params = {}) ⇒ Object

Gets the current pending invites

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.Organization.read, all.User, all.User.read, org.*, or org.pendingInvites.

Parameters:

  • string orgId - ID associated with the organization

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/losant_rest/org.rb', line 344

def pending_invites(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)

  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :get,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#remove_member(params = {}) ⇒ Object

Removes a member from the org

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.removeMember.

Parameters:

  • string orgId - ID associated with the organization

  • string userId - Id of user to remove

  • string summaryExclude - Comma-separated list of summary fields to exclude from org summary

  • string summaryInclude - Comma-separated list of summary fields to include in org summary

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
# File 'lib/losant_rest/org.rb', line 391

def remove_member(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("userId is required") unless params.has_key?(:userId)

  query_params[:userId] = params[:userId] if params.has_key?(:userId)
  query_params[:summaryExclude] = params[:summaryExclude] if params.has_key?(:summaryExclude)
  query_params[:summaryInclude] = params[:summaryInclude] if params.has_key?(:summaryInclude)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/member"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#revoke_invite(params = {}) ⇒ Object

Revokes an existing invite

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.revokeInvite.

Parameters:

  • string orgId - ID associated with the organization

  • string inviteId - Id of invite to revoke

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
# File 'lib/losant_rest/org.rb', line 440

def revoke_invite(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("inviteId is required") unless params.has_key?(:inviteId)

  query_params[:inviteId] = params[:inviteId] if params.has_key?(:inviteId)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/invites"

  @client.request(
    method: :delete,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end

#transfer_resources(params = {}) ⇒ Object

Moves resources to a new owner

Authentication: The client must be configured with a valid api access token to call this action. The token must include at least one of the following scopes: all.Organization, all.User, org.*, or org.transferResources.

Parameters:

  • string orgId - ID associated with the organization

  • hash transfer - Object containing properties of the transfer (api.losant.com/#/definitions/resourceTransfer)

  • string losantdomain - Domain scope of request (rarely needed)

  • boolean _actions - Return resource actions in response

  • boolean _links - Return resource link in response

  • boolean _embedded - Return embedded resources in response

Responses:

Errors:

Raises:

  • (ArgumentError)


487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
# File 'lib/losant_rest/org.rb', line 487

def transfer_resources(params = {})
  params = Utils.symbolize_hash_keys(params)
  query_params = { _actions: false, _links: true, _embedded: true }
  headers = {}
  body = nil

  raise ArgumentError.new("orgId is required") unless params.has_key?(:orgId)
  raise ArgumentError.new("transfer is required") unless params.has_key?(:transfer)

  body = params[:transfer] if params.has_key?(:transfer)
  headers[:losantdomain] = params[:losantdomain] if params.has_key?(:losantdomain)
  query_params[:_actions] = params[:_actions] if params.has_key?(:_actions)
  query_params[:_links] = params[:_links] if params.has_key?(:_links)
  query_params[:_embedded] = params[:_embedded] if params.has_key?(:_embedded)

  path = "/orgs/#{params[:orgId]}/transferResources"

  @client.request(
    method: :patch,
    path: path,
    query: query_params,
    headers: headers,
    body: body)
end