Class: SwaggerPetstoreOpenApi30::User
- Defined in:
- lib/swagger_petstore_open_api30/models/user.rb
Overview
User Model.
Instance Attribute Summary collapse
-
#email ⇒ String
TODO: Write general description for this method.
-
#first_name ⇒ String
TODO: Write general description for this method.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#last_name ⇒ String
TODO: Write general description for this method.
-
#password ⇒ String
TODO: Write general description for this method.
-
#phone ⇒ String
TODO: Write general description for this method.
-
#user_status ⇒ Integer
User Status.
-
#username ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
- .from_element(root) ⇒ Object
-
.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(id: SKIP, username: SKIP, first_name: SKIP, last_name: SKIP, email: SKIP, password: SKIP, phone: SKIP, user_status: SKIP, additional_properties: nil) ⇒ User
constructor
A new instance of User.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
- #to_xml_element(doc, root_name) ⇒ 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(id: SKIP, username: SKIP, first_name: SKIP, last_name: SKIP, email: SKIP, password: SKIP, phone: SKIP, user_status: SKIP, additional_properties: nil) ⇒ User
Returns a new instance of User.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 77 def initialize(id: SKIP, username: SKIP, first_name: SKIP, last_name: SKIP, email: SKIP, password: SKIP, phone: SKIP, user_status: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id unless id == SKIP @username = username unless username == SKIP @first_name = first_name unless first_name == SKIP @last_name = last_name unless last_name == SKIP @email = email unless email == SKIP @password = password unless password == SKIP @phone = phone unless phone == SKIP @user_status = user_status unless user_status == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#email ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 30 def email @email end |
#first_name ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 22 def first_name @first_name end |
#id ⇒ Integer
TODO: Write general description for this method
14 15 16 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 14 def id @id end |
#last_name ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 26 def last_name @last_name end |
#password ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 34 def password @password end |
#phone ⇒ String
TODO: Write general description for this method
38 39 40 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 38 def phone @phone end |
#user_status ⇒ Integer
User Status
42 43 44 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 42 def user_status @user_status end |
#username ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 18 def username @username end |
Class Method Details
.from_element(root) ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 127 def self.from_element(root) id = XmlUtilities.from_element(root, 'id', Integer) username = XmlUtilities.from_element(root, 'username', String) first_name = XmlUtilities.from_element(root, 'firstName', String) last_name = XmlUtilities.from_element(root, 'lastName', String) email = XmlUtilities.from_element(root, 'email', String) password = XmlUtilities.from_element(root, 'password', String) phone = XmlUtilities.from_element(root, 'phone', String) user_status = XmlUtilities.from_element(root, 'userStatus', Integer) new(id: id, username: username, first_name: first_name, last_name: last_name, email: email, password: password, phone: phone, user_status: user_status, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 95 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : SKIP username = hash.key?('username') ? hash['username'] : SKIP first_name = hash.key?('firstName') ? hash['firstName'] : SKIP last_name = hash.key?('lastName') ? hash['lastName'] : SKIP email = hash.key?('email') ? hash['email'] : SKIP password = hash.key?('password') ? hash['password'] : SKIP phone = hash.key?('phone') ? hash['phone'] : SKIP user_status = hash.key?('userStatus') ? hash['userStatus'] : SKIP # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. User.new(id: id, username: username, first_name: first_name, last_name: last_name, email: email, password: password, phone: phone, user_status: user_status, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 45 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['username'] = 'username' @_hash['first_name'] = 'firstName' @_hash['last_name'] = 'lastName' @_hash['email'] = 'email' @_hash['password'] = 'password' @_hash['phone'] = 'phone' @_hash['user_status'] = 'userStatus' @_hash end |
.nullables ⇒ Object
An array for nullable fields
73 74 75 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 73 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 59 def self.optionals %w[ id username first_name last_name email password phone user_status ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
174 175 176 177 178 179 180 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 174 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, username: #{@username.inspect}, first_name:"\ " #{@first_name.inspect}, last_name: #{@last_name.inspect}, email: #{@email.inspect},"\ " password: #{@password.inspect}, phone: #{@phone.inspect}, user_status:"\ " #{@user_status.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
166 167 168 169 170 171 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 166 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, username: #{@username}, first_name: #{@first_name}, last_name:"\ " #{@last_name}, email: #{@email}, password: #{@password}, phone: #{@phone}, user_status:"\ " #{@user_status}, additional_properties: #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/swagger_petstore_open_api30/models/user.rb', line 148 def to_xml_element(doc, root_name) root = doc.create_element(root_name) XmlUtilities.add_as_subelement(doc, root, 'id', id) XmlUtilities.add_as_subelement(doc, root, 'username', username) XmlUtilities.add_as_subelement(doc, root, 'firstName', first_name) XmlUtilities.add_as_subelement(doc, root, 'lastName', last_name) XmlUtilities.add_as_subelement(doc, root, 'email', email) XmlUtilities.add_as_subelement(doc, root, 'password', password) XmlUtilities.add_as_subelement(doc, root, 'phone', phone) XmlUtilities.add_as_subelement(doc, root, 'userStatus', user_status) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |