class LosantRest::Me

Class containing all the actions for the Me Resource

Public Class Methods

new(client) click to toggle source
# File lib/losant_rest/me.rb, line 30
def initialize(client)
  @client = client
end

Public Instance Methods

add_recent_item(params = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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 = {}) click to toggle source

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:

# 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
get(params = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 362
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 = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 409
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 = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 456
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 = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 500
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 = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 542
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 = {}) click to toggle source

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:

# File lib/losant_rest/me.rb, line 585
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