Class: Levelup::Requests::CreateUser

Inherits:
Base show all
Includes:
Templates::AppAuthenticated
Defined in:
lib/levelup/requests/create_user.rb

Overview

Represents a request to create a new user with the specified list of permissions.

Constant Summary

Constants inherited from Base

Base::ALLOWED_REQUEST_METHODS

Instance Attribute Summary collapse

Attributes included from Templates::AppAuthenticated

#app_access_token

Instance Method Summary collapse

Methods included from Templates::AppAuthenticated

#auth_type

Methods inherited from Base

#auth_type, #headers, instance_variables_excluded_from_hash, #send_to_api

Methods inherited from Templates::DataParcel

excluded?, #initialize, instance_variables_excluded_from_hash

Constructor Details

This class inherits a constructor from Levelup::Templates::DataParcel

Instance Attribute Details

#emailObject

An array of Item objects (or hashes representing them) representing all items purchased by this order.



9
10
11
# File 'lib/levelup/requests/create_user.rb', line 9

def email
  @email
end

#first_nameObject

Returns the value of attribute first_name.



10
11
12
# File 'lib/levelup/requests/create_user.rb', line 10

def first_name
  @first_name
end

#last_nameObject

Returns the value of attribute last_name.



11
12
13
# File 'lib/levelup/requests/create_user.rb', line 11

def last_name
  @last_name
end

#permission_keynamesObject

Returns the value of attribute permission_keynames.



12
13
14
# File 'lib/levelup/requests/create_user.rb', line 12

def permission_keynames
  @permission_keynames
end

Instance Method Details

#bodyObject



14
15
16
17
18
19
20
21
# File 'lib/levelup/requests/create_user.rb', line 14

def body
  user_hash = {
    email: email,
    first_name: first_name,
    last_name: last_name
  }
  { user: user_hash, permission_keynames: permission_keynames }
end

#response_from_hash(hash) ⇒ Object



23
24
25
26
27
# File 'lib/levelup/requests/create_user.rb', line 23

def response_from_hash(hash)
  hash['user'] = OpenStruct.new(hash['user'])

  Responses::Success.new(hash)
end