Class: NewStoreApi::User
- Defined in:
- lib/new_store_api/models/user.rb
Overview
User Model.
Instance Attribute Summary collapse
-
#associate_id ⇒ String
External identifier for the NewStore plattform.
-
#created_at ⇒ DateTime
External identifier for the NewStore plattform.
-
#email ⇒ String
Email address of the user.
-
#external_directory ⇒ TrueClass | FalseClass
User is managed by an external directory.
-
#first_name ⇒ String
First name of the user.
-
#id ⇒ String
Identifier of the user.
-
#is_active ⇒ TrueClass | FalseClass
Whether the user can login or not.
-
#last_login_at ⇒ DateTime
Shows last login time of the user.
-
#last_name ⇒ String
Last name of the user.
-
#phone ⇒ String
Telephone number of the user.
-
#roles ⇒ Array[RoleItem]
List of roles the user is assigned to.
-
#updated_at ⇒ DateTime
List of roles the user is assigned to.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(associate_id = SKIP, created_at = SKIP, email = SKIP, external_directory = SKIP, first_name = SKIP, id = SKIP, is_active = SKIP, last_login_at = SKIP, last_name = SKIP, phone = SKIP, roles = SKIP, updated_at = SKIP) ⇒ User
constructor
A new instance of User.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_last_login_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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, created_at = SKIP, email = SKIP, external_directory = SKIP, first_name = SKIP, id = SKIP, is_active = SKIP, last_login_at = SKIP, last_name = SKIP, phone = SKIP, roles = SKIP, updated_at = SKIP) ⇒ User
Returns a new instance of User.
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/new_store_api/models/user.rb', line 105 def initialize(associate_id = SKIP, created_at = SKIP, email = SKIP, external_directory = SKIP, first_name = SKIP, id = SKIP, is_active = SKIP, last_login_at = SKIP, last_name = SKIP, phone = SKIP, roles = SKIP, updated_at = SKIP) @associate_id = associate_id unless associate_id == SKIP @created_at = created_at unless created_at == SKIP @email = email unless email == SKIP @external_directory = external_directory unless external_directory == SKIP @first_name = first_name unless first_name == SKIP @id = id unless id == SKIP @is_active = is_active unless is_active == SKIP @last_login_at = last_login_at unless last_login_at == SKIP @last_name = last_name unless last_name == SKIP @phone = phone unless phone == SKIP @roles = roles unless roles == SKIP @updated_at = updated_at unless updated_at == SKIP end |
Instance Attribute Details
#associate_id ⇒ String
External identifier for the NewStore plattform. Formerly known as "newstore_id".
16 17 18 |
# File 'lib/new_store_api/models/user.rb', line 16 def associate_id @associate_id end |
#created_at ⇒ DateTime
External identifier for the NewStore plattform. Formerly known as "newstore_id".
21 22 23 |
# File 'lib/new_store_api/models/user.rb', line 21 def created_at @created_at end |
#email ⇒ String
Email address of the user.
25 26 27 |
# File 'lib/new_store_api/models/user.rb', line 25 def email @email end |
#external_directory ⇒ TrueClass | FalseClass
User is managed by an external directory.
29 30 31 |
# File 'lib/new_store_api/models/user.rb', line 29 def external_directory @external_directory end |
#first_name ⇒ String
First name of the user.
33 34 35 |
# File 'lib/new_store_api/models/user.rb', line 33 def first_name @first_name end |
#id ⇒ String
Identifier of the user.
37 38 39 |
# File 'lib/new_store_api/models/user.rb', line 37 def id @id end |
#is_active ⇒ TrueClass | FalseClass
Whether the user can login or not.
41 42 43 |
# File 'lib/new_store_api/models/user.rb', line 41 def is_active @is_active end |
#last_login_at ⇒ DateTime
Shows last login time of the user. If user never logged in the property is not presence.
46 47 48 |
# File 'lib/new_store_api/models/user.rb', line 46 def last_login_at @last_login_at end |
#last_name ⇒ String
Last name of the user.
50 51 52 |
# File 'lib/new_store_api/models/user.rb', line 50 def last_name @last_name end |
#phone ⇒ String
Telephone number of the user.
54 55 56 |
# File 'lib/new_store_api/models/user.rb', line 54 def phone @phone end |
#roles ⇒ Array[RoleItem]
List of roles the user is assigned to.
58 59 60 |
# File 'lib/new_store_api/models/user.rb', line 58 def roles @roles end |
#updated_at ⇒ DateTime
List of roles the user is assigned to.
62 63 64 |
# File 'lib/new_store_api/models/user.rb', line 62 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/new_store_api/models/user.rb', line 124 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. associate_id = hash.key?('associate_id') ? hash['associate_id'] : SKIP created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) else SKIP end email = hash.key?('email') ? hash['email'] : SKIP external_directory = hash.key?('external_directory') ? hash['external_directory'] : SKIP first_name = hash.key?('first_name') ? hash['first_name'] : SKIP id = hash.key?('id') ? hash['id'] : SKIP is_active = hash.key?('is_active') ? hash['is_active'] : SKIP last_login_at = if hash.key?('last_login_at') (DateTimeHelper.from_rfc3339(hash['last_login_at']) if hash['last_login_at']) else SKIP end last_name = hash.key?('last_name') ? hash['last_name'] : SKIP phone = hash.key?('phone') ? hash['phone'] : SKIP # Parameter is an array, so we need to iterate through it roles = nil unless hash['roles'].nil? roles = [] hash['roles'].each do |structure| roles << (RoleItem.from_hash(structure) if structure) end end roles = SKIP unless hash.key?('roles') updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) else SKIP end # Create object from extracted values. User.new(associate_id, created_at, email, external_directory, first_name, id, is_active, last_login_at, last_name, phone, roles, updated_at) end |
.names ⇒ Object
A mapping from model property names to API property names.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/new_store_api/models/user.rb', line 65 def self.names @_hash = {} if @_hash.nil? @_hash['associate_id'] = 'associate_id' @_hash['created_at'] = 'created_at' @_hash['email'] = 'email' @_hash['external_directory'] = 'external_directory' @_hash['first_name'] = 'first_name' @_hash['id'] = 'id' @_hash['is_active'] = 'is_active' @_hash['last_login_at'] = 'last_login_at' @_hash['last_name'] = 'last_name' @_hash['phone'] = 'phone' @_hash['roles'] = 'roles' @_hash['updated_at'] = 'updated_at' @_hash end |
.nullables ⇒ Object
An array for nullable fields
101 102 103 |
# File 'lib/new_store_api/models/user.rb', line 101 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/new_store_api/models/user.rb', line 83 def self.optionals %w[ associate_id created_at email external_directory first_name id is_active last_login_at last_name phone roles updated_at ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
200 201 202 203 204 205 206 207 |
# File 'lib/new_store_api/models/user.rb', line 200 def inspect class_name = self.class.name.split('::').last "<#{class_name} associate_id: #{@associate_id.inspect}, created_at: #{@created_at.inspect},"\ " email: #{@email.inspect}, external_directory: #{@external_directory.inspect}, first_name:"\ " #{@first_name.inspect}, id: #{@id.inspect}, is_active: #{@is_active.inspect},"\ " last_login_at: #{@last_login_at.inspect}, last_name: #{@last_name.inspect}, phone:"\ " #{@phone.inspect}, roles: #{@roles.inspect}, updated_at: #{@updated_at.inspect}>" end |
#to_custom_created_at ⇒ Object
178 179 180 |
# File 'lib/new_store_api/models/user.rb', line 178 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_last_login_at ⇒ Object
182 183 184 |
# File 'lib/new_store_api/models/user.rb', line 182 def to_custom_last_login_at DateTimeHelper.to_rfc3339(last_login_at) end |
#to_custom_updated_at ⇒ Object
186 187 188 |
# File 'lib/new_store_api/models/user.rb', line 186 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
191 192 193 194 195 196 197 |
# File 'lib/new_store_api/models/user.rb', line 191 def to_s class_name = self.class.name.split('::').last "<#{class_name} associate_id: #{@associate_id}, created_at: #{@created_at}, email:"\ " #{@email}, external_directory: #{@external_directory}, first_name: #{@first_name}, id:"\ " #{@id}, is_active: #{@is_active}, last_login_at: #{@last_login_at}, last_name:"\ " #{@last_name}, phone: #{@phone}, roles: #{@roles}, updated_at: #{@updated_at}>" end |