Class: SwaggerPetstoreOpenApi30::Order

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

Overview

Order 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, pet_id = SKIP, quantity = SKIP, ship_date = SKIP, order_status = OrderStatusEnum::APPROVED, complete = SKIP) ⇒ Order

Returns a new instance of Order.



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

def initialize(id = SKIP, pet_id = SKIP, quantity = SKIP, ship_date = SKIP,
               order_status = OrderStatusEnum::APPROVED, complete = SKIP)
  @id = id unless id == SKIP
  @pet_id = pet_id unless pet_id == SKIP
  @quantity = quantity unless quantity == SKIP
  @ship_date = ship_date unless ship_date == SKIP
  @order_status = order_status unless order_status == SKIP
  @complete = complete unless complete == SKIP
end

Instance Attribute Details

#completeTrueClass | FalseClass

Order Status

Returns:

  • (TrueClass | FalseClass)


35
36
37
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 35

def complete
  @complete
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


15
16
17
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 15

def id
  @id
end

#order_statusOrderStatusEnum

Order Status

Returns:



31
32
33
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 31

def order_status
  @order_status
end

#pet_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


19
20
21
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 19

def pet_id
  @pet_id
end

#quantityInteger

TODO: Write general description for this method

Returns:

  • (Integer)


23
24
25
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 23

def quantity
  @quantity
end

#ship_dateDateTime

TODO: Write general description for this method

Returns:

  • (DateTime)


27
28
29
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 27

def ship_date
  @ship_date
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
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 77

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : SKIP
  pet_id = hash.key?('petId') ? hash['petId'] : SKIP
  quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
  ship_date = if hash.key?('shipDate')
                (DateTimeHelper.from_rfc3339(hash['shipDate']) if hash['shipDate'])
              else
                SKIP
              end
  order_status = hash['orderStatus'] ||= OrderStatusEnum::APPROVED
  complete = hash.key?('complete') ? hash['complete'] : SKIP

  # Create object from extracted values.
  Order.new(id,
            pet_id,
            quantity,
            ship_date,
            order_status,
            complete)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['pet_id'] = 'petId'
  @_hash['quantity'] = 'quantity'
  @_hash['ship_date'] = 'shipDate'
  @_hash['order_status'] = 'orderStatus'
  @_hash['complete'] = 'complete'
  @_hash
end

.nullablesObject

An array for nullable fields



62
63
64
# File 'lib/swagger_petstore_open_api30/models/order.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/swagger_petstore_open_api30/models/order.rb', line 50

def self.optionals
  %w[
    id
    pet_id
    quantity
    ship_date
    order_status
    complete
  ]
end

Instance Method Details

#to_custom_ship_dateObject



101
102
103
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 101

def to_custom_ship_date
  DateTimeHelper.to_rfc3339(ship_date)
end