Class: NewStoreApi::GetUserinfoResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/get_userinfo_response.rb

Overview

Returns user information including permissions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(associate_id = SKIP, email = SKIP, first_name = SKIP, id = SKIP, last_name = SKIP, permissions = SKIP) ⇒ GetUserinfoResponse

Returns a new instance of GetUserinfoResponse.



66
67
68
69
70
71
72
73
74
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 66

def initialize(associate_id = SKIP, email = SKIP, first_name = SKIP,
               id = SKIP, last_name = SKIP, permissions = SKIP)
  @associate_id = associate_id unless associate_id == SKIP
  @email = email unless email == SKIP
  @first_name = first_name unless first_name == SKIP
  @id = id unless id == SKIP
  @last_name = last_name unless last_name == SKIP
  @permissions = permissions unless permissions == SKIP
end

Instance Attribute Details

#associate_idString

External identifier for the NewStore plattform. Formerly known as "newstore_id".

Returns:

  • (String)


15
16
17
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 15

def associate_id
  @associate_id
end

#emailString

Email address of the user.

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 19

def email
  @email
end

#first_nameString

First name of the user.

Returns:

  • (String)


23
24
25
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 23

def first_name
  @first_name
end

#idString

Identifier of the user.

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 27

def id
  @id
end

#last_nameString

Last name of the user.

Returns:

  • (String)


31
32
33
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 31

def last_name
  @last_name
end

#permissionsArray[Permission]

Last name of the user.

Returns:



35
36
37
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 35

def permissions
  @permissions
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  associate_id = hash.key?('associate_id') ? hash['associate_id'] : SKIP
  email = hash.key?('email') ? hash['email'] : SKIP
  first_name = hash.key?('first_name') ? hash['first_name'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  last_name = hash.key?('last_name') ? hash['last_name'] : SKIP
  # Parameter is an array, so we need to iterate through it
  permissions = nil
  unless hash['permissions'].nil?
    permissions = []
    hash['permissions'].each do |structure|
      permissions << (Permission.from_hash(structure) if structure)
    end
  end

  permissions = SKIP unless hash.key?('permissions')

  # Create object from extracted values.
  GetUserinfoResponse.new(associate_id,
                          email,
                          first_name,
                          id,
                          last_name,
                          permissions)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['associate_id'] = 'associate_id'
  @_hash['email'] = 'email'
  @_hash['first_name'] = 'first_name'
  @_hash['id'] = 'id'
  @_hash['last_name'] = 'last_name'
  @_hash['permissions'] = 'permissions'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 62

def self.nullables
  []
end

.optionalsObject

An array for optional fields



50
51
52
53
54
55
56
57
58
59
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 50

def self.optionals
  %w[
    associate_id
    email
    first_name
    id
    last_name
    permissions
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id.inspect}, email: #{@email.inspect},"\
  " first_name: #{@first_name.inspect}, id: #{@id.inspect}, last_name: #{@last_name.inspect},"\
  " permissions: #{@permissions.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



107
108
109
110
111
# File 'lib/new_store_api/models/get_userinfo_response.rb', line 107

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} associate_id: #{@associate_id}, email: #{@email}, first_name:"\
  " #{@first_name}, id: #{@id}, last_name: #{@last_name}, permissions: #{@permissions}>"
end