Class: LosantRest::Me

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

Overview

Class containing all the actions for the Me Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Me

Returns a new instance of Me.



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

def initialize(client)
  @client = client
end

Instance Method Details

#add_recent_item(params = {}) ⇒ Object

Adds an item to a recent item list

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.User, me.*, or me.addRecentItem.

Parameters:

  • hash data - Object containing recent item info (api.losant.com/#/definitions/recentItem)

  • 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)


54
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/me.rb', line 54

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

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

  body = params[:data] if params.has_key?(:data)
  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 = "/me/recentItems"

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

#change_password(params = {}) ⇒ Object

Changes the current user's password and optionally logs out all other sessions

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.User, me.*, or me.changePassword.

Parameters:

  • hash data - Object containing the password change info (api.losant.com/#/definitions/changePassword)

  • 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)


98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/losant_rest/me.rb', line 98

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

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

  body = params[:data] if params.has_key?(:data)
  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 = "/me/changePassword"

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

#delete(params = {}) ⇒ Object

Deletes the current user

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.User, me.*, or me.delete.

Parameters:

  • hash credentials - User authentication credentials (api.losant.com/#/definitions/userCredentials)

  • 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)


142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/losant_rest/me.rb', line 142

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

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

  body = params[:credentials] if params.has_key?(:credentials)
  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 = "/me/delete"

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

#disable_two_factor_auth(params = {}) ⇒ Object

Disables two factor auth for the current user

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.User, me.*, or me.disableTwoFactorAuth.

Parameters:

  • hash data - Object containing two factor auth properties (api.losant.com/#/definitions/disableTwoFactorAuth)

  • 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)


186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/losant_rest/me.rb', line 186

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

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

  body = params[:data] if params.has_key?(:data)
  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 = "/me/disableTwoFactorAuth"

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

#disconnect_github(params = {}) ⇒ Object

Disconnects the user from Github

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.User, me.*, or me.disconnectGithub.

Parameters:

  • 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:



229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/losant_rest/me.rb', line 229

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


  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 = "/me/disconnectGithub"

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

#enable_two_factor_auth(params = {}) ⇒ Object

Enables two factor auth for the current user

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.User, me.*, or me.enableTwoFactorAuth.

Parameters:

  • hash data - Object containing two factor auth properties (api.losant.com/#/definitions/enableTwoFactorAuth)

  • 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)


271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# File 'lib/losant_rest/me.rb', line 271

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

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

  body = params[:data] if params.has_key?(:data)
  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 = "/me/enableTwoFactorAuth"

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

#fetch_recent_items(params = {}) ⇒ Object

Gets a recent item list

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.User, all.User.read, me.*, or me.fetchRecentItems.

Parameters:

  • string parentId - Parent id of the recent list

  • undefined itemType - Item type to get the recent list of. Accepted values are: application, device, flow, dashboard, 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)


316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
# File 'lib/losant_rest/me.rb', line 316

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

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

  query_params[:parentId] = params[:parentId] if params.has_key?(:parentId)
  query_params[:itemType] = params[:itemType] if params.has_key?(:itemType)
  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 = "/me/recentItems"

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

#generate_two_factor_auth(params = {}) ⇒ Object

Returns the two factor auth key for a user

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.User, me.*, or me.generateTwoFactorAuth.

Parameters:

  • 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:



360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/losant_rest/me.rb', line 360

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


  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 = "/me/generateTwoFactorAuth"

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

#get(params = {}) ⇒ Object

Retrieves information on the current user

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.User, all.User.read, me.*, or me.get.

Parameters:

  • undefined includeRecent - Should the user include recent app/dashboard info

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

  • string summaryInclude - Comma-separated list of summary fields to include in user 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:



403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/losant_rest/me.rb', line 403

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


  query_params[:includeRecent] = params[:includeRecent] if params.has_key?(:includeRecent)
  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 = "/me"

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

#patch(params = {}) ⇒ Object

Updates information about the current user

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.User, me.*, or me.patch.

Parameters:

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

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

  • string summaryInclude - Comma-separated list of summary fields to include in user 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)


450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/losant_rest/me.rb', line 450

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

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

  body = params[:user] if params.has_key?(:user)
  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 = "/me"

  @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 the current user 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.User, all.User.read, me.*, or me.payloadCounts.

Parameters:

  • 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:



497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
# File 'lib/losant_rest/me.rb', line 497

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


  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 = "/me/payloadCounts"

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

#refresh_token(params = {}) ⇒ Object

Returns a new auth token based on the current auth token

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.User, or me.*.

Parameters:

  • 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:



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/losant_rest/me.rb', line 541

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


  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 = "/me/refreshToken"

  @client.request(
    method: :get,
    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.User, me.*, or me.transferResources.

Parameters:

  • 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)


583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/losant_rest/me.rb', line 583

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

  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 = "/me/transferResources"

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

#verify_email(params = {}) ⇒ Object

Sends an email verification to the user

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.User, me.*, or me.verifyEmail.

Parameters:

  • 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:



626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
# File 'lib/losant_rest/me.rb', line 626

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


  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 = "/me/verify-email"

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