# The MIT License (MIT) # # Copyright (c) 2024 Losant IoT, Inc. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. require "json" module PlatformRest # Class containing all the actions for the Me Resource class Me def initialize(client) @client = client end # 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 (https://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: # * 200 - Updated recent item list (https://api.losant.com/#/definitions/recentItemList) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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 (https://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: # * 200 - A new, valid, auth token (potentially all previous tokens are now invalid) (https://api.losant.com/#/definitions/authedUser) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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 (https://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: # * 200 - If the user was successfully deleted (https://api.losant.com/#/definitions/success) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # Returns device counts by day 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.deviceCounts. # # Parameters: # * {string} start - Start of range for device count query (ms since epoch) # * {string} end - End of range for device 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: # * 200 - Device counts by day (https://api.losant.com/#/definitions/deviceCounts) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) def device_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/deviceCounts" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # Disables multi-factor authentication 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 multi-factor authentication properties (https://api.losant.com/#/definitions/multiFactorAuthDisable) # * {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: # * 200 - Updated user information (https://api.losant.com/#/definitions/me) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Updated user information (https://api.losant.com/#/definitions/me) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # Enables multi-factor authentication 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 multi-factor authentication properties (https://api.losant.com/#/definitions/multiFactorAuthEnable) # * {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: # * 200 - Updated user information (https://api.losant.com/#/definitions/me) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Recent item list (https://api.losant.com/#/definitions/recentItemList) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # Returns the multi-factor authentication key 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.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: # * 200 - Multi-factor authentication info (https://api.losant.com/#/definitions/multiFactorAuthInfo) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Current user information (https://api.losant.com/#/definitions/me) # # Errors: 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 # Retrieves information for an invitation 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.User, all.User.read, me.*, or me.invite. # # Parameters: # * {string} inviteId - ID associated with the invitation # * {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: # * 200 - Information about invitation (https://api.losant.com/#/definitions/orgInviteUser) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if invite not found (https://api.losant.com/#/definitions/error) def invite(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("inviteId is required") unless 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 = "/me/invites/#{params[:inviteId]}" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # Retrieves pending organization invitations 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, all.User.read, me.*, or me.invites. # # 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: # * 200 - Information about invitations (https://api.losant.com/#/definitions/orgInvitesUser) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) def invites(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/invites" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # Returns notebook execution usage by day 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.notebookMinuteCounts. # # Parameters: # * {string} start - Start of range for notebook execution query (ms since epoch) # * {string} end - End of range for notebook execution 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: # * 200 - Notebook usage information (https://api.losant.com/#/definitions/notebookMinuteCounts) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) def notebook_minute_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/notebookMinuteCounts" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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 (https://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: # * 200 - Updated user information (https://api.losant.com/#/definitions/me) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - Payload counts, by type and source (https://api.losant.com/#/definitions/payloadStats) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # Returns payload counts per resolution in 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.payloadCountsBreakdown. # # 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} resolution - Resolution in milliseconds. Accepted values are: 86400000, 3600000 # * {string} asBytes - If the resulting stats should be returned as bytes # * {string} includeNonBillable - If non-billable payloads should be included in the result # * {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: # * 200 - Sum of payload counts by date (https://api.losant.com/#/definitions/payloadCountsBreakdown) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) def payload_counts_breakdown(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) query_params[:resolution] = params[:resolution] if params.has_key?(:resolution) query_params[:asBytes] = params[:asBytes] if params.has_key?(:asBytes) query_params[:includeNonBillable] = params[:includeNonBillable] if params.has_key?(:includeNonBillable) 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/payloadCountsBreakdown" @client.request( method: :get, path: path, query: query_params, headers: headers, body: body) end # 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: # * 200 - Successful token regeneration (https://api.losant.com/#/definitions/authedUser) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 401 - Unauthorized error if authentication fails (https://api.losant.com/#/definitions/error) 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 # Accepts or rejects an invitation 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.User, me.*, or me.respondToInvite. # # Parameters: # * {string} inviteId - ID associated with the invitation # * {hash} response - Response to invitation (https://api.losant.com/#/definitions/orgInviteActionUser) # * {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: # * 200 - Acceptance or rejection of invitation (https://api.losant.com/#/definitions/orgInviteResultUser) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) # * 404 - Error if invitation not found (https://api.losant.com/#/definitions/error) # * 410 - Error if invitation has expired (https://api.losant.com/#/definitions/error) def respond_to_invite(params = {}) params = Utils.symbolize_hash_keys(params) query_params = { _actions: false, _links: true, _embedded: true } headers = {} body = nil raise ArgumentError.new("inviteId is required") unless params.has_key?(:inviteId) raise ArgumentError.new("response is required") unless params.has_key?(:response) body = params[:response] if params.has_key?(:response) 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/invites/#{params[:inviteId]}" @client.request( method: :post, path: path, query: query_params, headers: headers, body: body) end # 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 (https://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: # * 200 - If resource transfer was successful (https://api.losant.com/#/definitions/success) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 # 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: # * 200 - If email verification was successfully sent (https://api.losant.com/#/definitions/success) # # Errors: # * 400 - Error if malformed request (https://api.losant.com/#/definitions/error) 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 end end