Class: SwaggerPetstoreOpenApi30::Order
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- SwaggerPetstoreOpenApi30::Order
- Defined in:
- lib/swagger_petstore_open_api30/models/order.rb
Overview
Order Model.
Instance Attribute Summary collapse
-
#complete ⇒ TrueClass | FalseClass
Order Status.
-
#id ⇒ Integer
TODO: Write general description for this method.
-
#pet_id ⇒ Integer
TODO: Write general description for this method.
-
#quantity ⇒ Integer
TODO: Write general description for this method.
-
#ship_date ⇒ DateTime
TODO: Write general description for this method.
-
#status ⇒ OrderStatus
Order Status.
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, pet_id: SKIP, quantity: SKIP, ship_date: SKIP, status: SKIP, complete: SKIP, additional_properties: nil) ⇒ Order
constructor
A new instance of Order.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_ship_date ⇒ Object
-
#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, pet_id: SKIP, quantity: SKIP, ship_date: SKIP, status: SKIP, complete: SKIP, additional_properties: nil) ⇒ Order
Returns a new instance of Order.
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 66 def initialize(id: SKIP, pet_id: SKIP, quantity: SKIP, ship_date: SKIP, status: SKIP, complete: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 @status = status unless status == SKIP @complete = complete unless complete == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#complete ⇒ TrueClass | FalseClass
Order Status
35 36 37 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 35 def complete @complete end |
#id ⇒ Integer
TODO: Write general description for this method
15 16 17 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 15 def id @id end |
#pet_id ⇒ Integer
TODO: Write general description for this method
19 20 21 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 19 def pet_id @pet_id end |
#quantity ⇒ Integer
TODO: Write general description for this method
23 24 25 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 23 def quantity @quantity end |
#ship_date ⇒ DateTime
TODO: Write general description for this method
27 28 29 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 27 def ship_date @ship_date end |
#status ⇒ OrderStatus
Order Status
31 32 33 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 31 def status @status end |
Class Method Details
.from_element(root) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 117 def self.from_element(root) id = XmlUtilities.from_element(root, 'id', Integer) pet_id = XmlUtilities.from_element(root, 'petId', Integer) quantity = XmlUtilities.from_element(root, 'quantity', Integer) ship_date = XmlUtilities.from_element(root, 'shipDate', String, datetime_format: 'rfc3339') status = XmlUtilities.from_element(root, 'status', String) complete = XmlUtilities.from_element(root, 'complete', TrueClass) new(id: id, pet_id: pet_id, quantity: quantity, ship_date: ship_date, status: status, complete: complete, additional_properties: additional_properties) end |
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 81 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 status = hash.key?('status') ? hash['status'] : SKIP complete = hash.key?('complete') ? hash['complete'] : 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. Order.new(id: id, pet_id: pet_id, quantity: quantity, ship_date: ship_date, status: status, complete: complete, additional_properties: additional_properties) end |
.names ⇒ Object
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['status'] = 'status' @_hash['complete'] = 'complete' @_hash end |
.nullables ⇒ Object
An array for nullable fields
62 63 64 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 62 def self.nullables [] end |
.optionals ⇒ Object
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 status complete ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
160 161 162 163 164 165 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 160 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, pet_id: #{@pet_id.inspect}, quantity:"\ " #{@quantity.inspect}, ship_date: #{@ship_date.inspect}, status: #{@status.inspect},"\ " complete: #{@complete.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_ship_date ⇒ Object
113 114 115 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 113 def to_custom_ship_date DateTimeHelper.to_rfc3339(ship_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
152 153 154 155 156 157 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 152 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, pet_id: #{@pet_id}, quantity: #{@quantity}, ship_date:"\ " #{@ship_date}, status: #{@status}, complete: #{@complete}, additional_properties:"\ " #{@additional_properties}>" end |
#to_xml_element(doc, root_name) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/swagger_petstore_open_api30/models/order.rb', line 135 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, 'petId', pet_id) XmlUtilities.add_as_subelement(doc, root, 'quantity', quantity) XmlUtilities.add_as_subelement(doc, root, 'shipDate', ship_date, datetime_format: 'rfc3339') XmlUtilities.add_as_subelement(doc, root, 'status', status) XmlUtilities.add_as_subelement(doc, root, 'complete', complete) XmlUtilities.add_as_subelement(doc, root, 'additional_properties', additional_properties) root end |