Class: SwaggerPetstoreOpenApi30::Customer

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/swagger_petstore_open_api30/models/customer.rb

Overview

Customer Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = SKIP, username = SKIP, address = SKIP) ⇒ Customer

Returns a new instance of Customer.



47
48
49
50
51
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 47

def initialize(id = SKIP, username = SKIP, address = SKIP)
  @id = id unless id == SKIP
  @username = username unless username == SKIP
  @address = address unless address == SKIP
end

Instance Attribute Details

#addressArray[Address]

TODO: Write general description for this method

Returns:



22
23
24
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 22

def address
  @address
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 14

def id
  @id
end

#usernameString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 18

def username
  @username
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 54

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
  # Parameter is an array, so we need to iterate through it
  address = nil
  unless hash['address'].nil?
    address = []
    hash['address'].each do |structure|
      address << (Address.from_hash(structure) if structure)
    end
  end

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

  # Create object from extracted values.
  Customer.new(id,
               username,
               address)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
31
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['username'] = 'username'
  @_hash['address'] = 'address'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



34
35
36
37
38
39
40
# File 'lib/swagger_petstore_open_api30/models/customer.rb', line 34

def self.optionals
  %w[
    id
    username
    address
  ]
end