Class: LosantRest::OrgInvites

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

Overview

Class containing all the actions for the Org Invites Resource

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ OrgInvites

Returns a new instance of OrgInvites.



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

def initialize(client)
  @client = client
end

Instance Method Details

#get(params = {}) ⇒ Object

Gets information about an invite

Authentication: No api access token is required to call this action.

Parameters:

  • string token - The token associated with the invite

  • string email - The email associated with the invite

  • 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
77
78
# File 'lib/losant_rest/org_invites.rb', line 54

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

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

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

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

#post(params = {}) ⇒ Object

Accepts/Rejects an invite

Authentication: No api access token is required to call this action.

Parameters:

  • hash invite - Invite info and acceptance (api.losant.com/#/definitions/orgInviteAction)

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


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

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

  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 = "/invites"

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