wine_shipping 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/README.md +128 -0
  4. data/Rakefile +8 -0
  5. data/docs/Authentication.md +10 -0
  6. data/docs/BillingContactInfo.md +18 -0
  7. data/docs/DeliveryContactInfo.md +17 -0
  8. data/docs/Inventory.md +20 -0
  9. data/docs/InventoryApi.md +102 -0
  10. data/docs/InventoryMovementApi.md +100 -0
  11. data/docs/InventoryStatusRequest.md +13 -0
  12. data/docs/InventoryStatusResult.md +12 -0
  13. data/docs/ItemInfo.md +10 -0
  14. data/docs/OrderOnHold.md +19 -0
  15. data/docs/OrderOnHoldItem.md +11 -0
  16. data/docs/PackageItem.md +10 -0
  17. data/docs/PurchaseOrderDetails.md +10 -0
  18. data/docs/PurchaseOrderInfo.md +24 -0
  19. data/docs/PurchaseOrderItemInfo.md +10 -0
  20. data/docs/RecipientContactInfo.md +18 -0
  21. data/docs/RequestorInfo.md +11 -0
  22. data/docs/ReturnResult.md +12 -0
  23. data/docs/ReturnSalesOrderHeader.md +31 -0
  24. data/docs/ReturnSalesOrderLine.md +13 -0
  25. data/docs/ReturnsRequest.md +16 -0
  26. data/docs/SKUApi.md +54 -0
  27. data/docs/SKUDetails.md +10 -0
  28. data/docs/SKUInfo.md +20 -0
  29. data/docs/SalesOrderApi.md +240 -0
  30. data/docs/SalesOrderCancelRequest.md +9 -0
  31. data/docs/SalesOrderDetails.md +14 -0
  32. data/docs/SalesOrderInfo.md +20 -0
  33. data/docs/ShipmentInfo.md +13 -0
  34. data/docs/TrackingApi.md +55 -0
  35. data/docs/TrackingRequest.md +9 -0
  36. data/docs/TrackingResult.md +28 -0
  37. data/docs/TransferOrderDetails.md +10 -0
  38. data/docs/TransferOrderInfo.md +17 -0
  39. data/docs/TransferOrderItemInfo.md +10 -0
  40. data/docs/WarehouseInventoryStatus.md +19 -0
  41. data/git_push.sh +55 -0
  42. data/lib/.DS_Store +0 -0
  43. data/lib/wine_shipping.rb +75 -0
  44. data/lib/wine_shipping/api/inventory_api.rb +127 -0
  45. data/lib/wine_shipping/api/inventory_movement_api.rb +125 -0
  46. data/lib/wine_shipping/api/sales_order_api.rb +280 -0
  47. data/lib/wine_shipping/api/sku_api.rb +74 -0
  48. data/lib/wine_shipping/api/tracking_api.rb +75 -0
  49. data/lib/wine_shipping/api_client.rb +388 -0
  50. data/lib/wine_shipping/api_error.rb +38 -0
  51. data/lib/wine_shipping/configuration.rb +202 -0
  52. data/lib/wine_shipping/models/authentication.rb +201 -0
  53. data/lib/wine_shipping/models/billing_contact_info.rb +273 -0
  54. data/lib/wine_shipping/models/delivery_contact_info.rb +298 -0
  55. data/lib/wine_shipping/models/inventory.rb +291 -0
  56. data/lib/wine_shipping/models/inventory_status_request.rb +230 -0
  57. data/lib/wine_shipping/models/inventory_status_result.rb +221 -0
  58. data/lib/wine_shipping/models/item_info.rb +201 -0
  59. data/lib/wine_shipping/models/order_on_hold.rb +284 -0
  60. data/lib/wine_shipping/models/order_on_hold_item.rb +210 -0
  61. data/lib/wine_shipping/models/package_item.rb +201 -0
  62. data/lib/wine_shipping/models/purchase_order_details.rb +203 -0
  63. data/lib/wine_shipping/models/purchase_order_info.rb +361 -0
  64. data/lib/wine_shipping/models/purchase_order_item_info.rb +201 -0
  65. data/lib/wine_shipping/models/recipient_contact_info.rb +273 -0
  66. data/lib/wine_shipping/models/requestor_info.rb +210 -0
  67. data/lib/wine_shipping/models/return_result.rb +221 -0
  68. data/lib/wine_shipping/models/return_sales_order_header.rb +392 -0
  69. data/lib/wine_shipping/models/return_sales_order_line.rb +228 -0
  70. data/lib/wine_shipping/models/returns_request.rb +257 -0
  71. data/lib/wine_shipping/models/sales_order_cancel_request.rb +192 -0
  72. data/lib/wine_shipping/models/sales_order_details.rb +239 -0
  73. data/lib/wine_shipping/models/sales_order_info.rb +325 -0
  74. data/lib/wine_shipping/models/shipment_info.rb +274 -0
  75. data/lib/wine_shipping/models/sku_details.rb +201 -0
  76. data/lib/wine_shipping/models/sku_info.rb +325 -0
  77. data/lib/wine_shipping/models/tracking_request.rb +192 -0
  78. data/lib/wine_shipping/models/tracking_result.rb +365 -0
  79. data/lib/wine_shipping/models/transfer_order_details.rb +203 -0
  80. data/lib/wine_shipping/models/transfer_order_info.rb +264 -0
  81. data/lib/wine_shipping/models/transfer_order_item_info.rb +201 -0
  82. data/lib/wine_shipping/models/warehouse_inventory_status.rb +282 -0
  83. data/lib/wine_shipping/version.rb +15 -0
  84. data/spec/api/inventory_api_spec.rb +57 -0
  85. data/spec/api/inventory_movement_api_spec.rb +57 -0
  86. data/spec/api/sales_order_api_spec.rb +90 -0
  87. data/spec/api/sku_api_spec.rb +46 -0
  88. data/spec/api/tracking_api_spec.rb +46 -0
  89. data/spec/api_client_spec.rb +226 -0
  90. data/spec/configuration_spec.rb +42 -0
  91. data/spec/models/authentication_spec.rb +53 -0
  92. data/spec/models/billing_contact_info_spec.rb +101 -0
  93. data/spec/models/delivery_contact_info_spec.rb +99 -0
  94. data/spec/models/inventory_spec.rb +113 -0
  95. data/spec/models/inventory_status_request_spec.rb +71 -0
  96. data/spec/models/inventory_status_result_spec.rb +65 -0
  97. data/spec/models/item_info_spec.rb +53 -0
  98. data/spec/models/order_on_hold_item_spec.rb +59 -0
  99. data/spec/models/order_on_hold_spec.rb +107 -0
  100. data/spec/models/package_item_spec.rb +53 -0
  101. data/spec/models/purchase_order_details_spec.rb +53 -0
  102. data/spec/models/purchase_order_info_spec.rb +141 -0
  103. data/spec/models/purchase_order_item_info_spec.rb +53 -0
  104. data/spec/models/recipient_contact_info_spec.rb +101 -0
  105. data/spec/models/requestor_info_spec.rb +59 -0
  106. data/spec/models/return_result_spec.rb +65 -0
  107. data/spec/models/return_sales_order_header_spec.rb +179 -0
  108. data/spec/models/return_sales_order_line_spec.rb +71 -0
  109. data/spec/models/returns_request_spec.rb +89 -0
  110. data/spec/models/sales_order_cancel_request_spec.rb +47 -0
  111. data/spec/models/sales_order_details_spec.rb +77 -0
  112. data/spec/models/sales_order_info_spec.rb +117 -0
  113. data/spec/models/shipment_info_spec.rb +79 -0
  114. data/spec/models/sku_details_spec.rb +53 -0
  115. data/spec/models/sku_info_spec.rb +117 -0
  116. data/spec/models/tracking_request_spec.rb +47 -0
  117. data/spec/models/tracking_result_spec.rb +161 -0
  118. data/spec/models/transfer_order_details_spec.rb +53 -0
  119. data/spec/models/transfer_order_info_spec.rb +95 -0
  120. data/spec/models/transfer_order_item_info_spec.rb +53 -0
  121. data/spec/models/warehouse_inventory_status_spec.rb +107 -0
  122. data/spec/spec_helper.rb +111 -0
  123. data/wine_shipping.gemspec +45 -0
  124. metadata +390 -0
@@ -0,0 +1,361 @@
1
+ =begin
2
+ #API from Wineshipping
3
+
4
+ #Wineshipping API is a programmatically consumable service or an Application Programming Interface (API) platform designed to enable Wineshipping LLC's client applications to natively transmit and manage their order, view inventory, track shipments etc.<br /><br />In order to access API operations request a UserKey and Password from Wineshipping. For any questions please contact Wineshipping Helpdesk at <a href='mailto:IT-Help@wineshipping.com?Subject=API from Wineshipping'>IT-Help@wineshipping.com</a>.
5
+
6
+ OpenAPI spec version: V3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module WineShipping
16
+ class PurchaseOrderInfo
17
+ attr_accessor :customer_reference_no
18
+
19
+ attr_accessor :transport_method
20
+
21
+ attr_accessor :requested_date
22
+
23
+ attr_accessor :receive_to_location
24
+
25
+ attr_accessor :inventory_status_code
26
+
27
+ attr_accessor :reference_no
28
+
29
+ attr_accessor :first_name
30
+
31
+ attr_accessor :last_name
32
+
33
+ attr_accessor :company
34
+
35
+ attr_accessor :address
36
+
37
+ attr_accessor :address2
38
+
39
+ attr_accessor :city
40
+
41
+ attr_accessor :state
42
+
43
+ attr_accessor :zip_code
44
+
45
+ attr_accessor :phone_number
46
+
47
+ attr_accessor :email_address
48
+
49
+ attr_accessor :special_instruction
50
+
51
+ class EnumAttributeValidator
52
+ attr_reader :datatype
53
+ attr_reader :allowable_values
54
+
55
+ def initialize(datatype, allowable_values)
56
+ @allowable_values = allowable_values.map do |value|
57
+ case datatype.to_s
58
+ when /Integer/i
59
+ value.to_i
60
+ when /Float/i
61
+ value.to_f
62
+ else
63
+ value
64
+ end
65
+ end
66
+ end
67
+
68
+ def valid?(value)
69
+ !value || allowable_values.include?(value)
70
+ end
71
+ end
72
+
73
+ # Attribute mapping from ruby-style variable name to JSON key.
74
+ def self.attribute_map
75
+ {
76
+ :'customer_reference_no' => :'CustomerReferenceNo',
77
+ :'transport_method' => :'TransportMethod',
78
+ :'requested_date' => :'RequestedDate',
79
+ :'receive_to_location' => :'ReceiveToLocation',
80
+ :'inventory_status_code' => :'InventoryStatusCode',
81
+ :'reference_no' => :'ReferenceNo',
82
+ :'first_name' => :'FirstName',
83
+ :'last_name' => :'LastName',
84
+ :'company' => :'Company',
85
+ :'address' => :'Address',
86
+ :'address2' => :'Address2',
87
+ :'city' => :'City',
88
+ :'state' => :'State',
89
+ :'zip_code' => :'ZipCode',
90
+ :'phone_number' => :'PhoneNumber',
91
+ :'email_address' => :'EmailAddress',
92
+ :'special_instruction' => :'SpecialInstruction'
93
+ }
94
+ end
95
+
96
+ # Attribute type mapping.
97
+ def self.swagger_types
98
+ {
99
+ :'customer_reference_no' => :'String',
100
+ :'transport_method' => :'Integer',
101
+ :'requested_date' => :'DateTime',
102
+ :'receive_to_location' => :'String',
103
+ :'inventory_status_code' => :'String',
104
+ :'reference_no' => :'String',
105
+ :'first_name' => :'String',
106
+ :'last_name' => :'String',
107
+ :'company' => :'String',
108
+ :'address' => :'String',
109
+ :'address2' => :'String',
110
+ :'city' => :'String',
111
+ :'state' => :'String',
112
+ :'zip_code' => :'String',
113
+ :'phone_number' => :'String',
114
+ :'email_address' => :'String',
115
+ :'special_instruction' => :'String'
116
+ }
117
+ end
118
+
119
+ # Initializes the object
120
+ # @param [Hash] attributes Model attributes in the form of hash
121
+ def initialize(attributes = {})
122
+ return unless attributes.is_a?(Hash)
123
+
124
+ # convert string to symbol for hash key
125
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
126
+
127
+ if attributes.has_key?(:'CustomerReferenceNo')
128
+ self.customer_reference_no = attributes[:'CustomerReferenceNo']
129
+ end
130
+
131
+ if attributes.has_key?(:'TransportMethod')
132
+ self.transport_method = attributes[:'TransportMethod']
133
+ end
134
+
135
+ if attributes.has_key?(:'RequestedDate')
136
+ self.requested_date = attributes[:'RequestedDate']
137
+ end
138
+
139
+ if attributes.has_key?(:'ReceiveToLocation')
140
+ self.receive_to_location = attributes[:'ReceiveToLocation']
141
+ end
142
+
143
+ if attributes.has_key?(:'InventoryStatusCode')
144
+ self.inventory_status_code = attributes[:'InventoryStatusCode']
145
+ end
146
+
147
+ if attributes.has_key?(:'ReferenceNo')
148
+ self.reference_no = attributes[:'ReferenceNo']
149
+ end
150
+
151
+ if attributes.has_key?(:'FirstName')
152
+ self.first_name = attributes[:'FirstName']
153
+ end
154
+
155
+ if attributes.has_key?(:'LastName')
156
+ self.last_name = attributes[:'LastName']
157
+ end
158
+
159
+ if attributes.has_key?(:'Company')
160
+ self.company = attributes[:'Company']
161
+ end
162
+
163
+ if attributes.has_key?(:'Address')
164
+ self.address = attributes[:'Address']
165
+ end
166
+
167
+ if attributes.has_key?(:'Address2')
168
+ self.address2 = attributes[:'Address2']
169
+ end
170
+
171
+ if attributes.has_key?(:'City')
172
+ self.city = attributes[:'City']
173
+ end
174
+
175
+ if attributes.has_key?(:'State')
176
+ self.state = attributes[:'State']
177
+ end
178
+
179
+ if attributes.has_key?(:'ZipCode')
180
+ self.zip_code = attributes[:'ZipCode']
181
+ end
182
+
183
+ if attributes.has_key?(:'PhoneNumber')
184
+ self.phone_number = attributes[:'PhoneNumber']
185
+ end
186
+
187
+ if attributes.has_key?(:'EmailAddress')
188
+ self.email_address = attributes[:'EmailAddress']
189
+ end
190
+
191
+ if attributes.has_key?(:'SpecialInstruction')
192
+ self.special_instruction = attributes[:'SpecialInstruction']
193
+ end
194
+ end
195
+
196
+ # Show invalid properties with the reasons. Usually used together with valid?
197
+ # @return Array for valid properties with the reasons
198
+ def list_invalid_properties
199
+ invalid_properties = Array.new
200
+ invalid_properties
201
+ end
202
+
203
+ # Check to see if the all the properties in the model are valid
204
+ # @return true if the model is valid
205
+ def valid?
206
+ transport_method_validator = EnumAttributeValidator.new('Integer', ['1', '2'])
207
+ return false unless transport_method_validator.valid?(@transport_method)
208
+ true
209
+ end
210
+
211
+ # Custom attribute writer method checking allowed values (enum).
212
+ # @param [Object] transport_method Object to be assigned
213
+ def transport_method=(transport_method)
214
+ validator = EnumAttributeValidator.new('Integer', ['1', '2'])
215
+ unless validator.valid?(transport_method)
216
+ fail ArgumentError, 'invalid value for "transport_method", must be one of #{validator.allowable_values}.'
217
+ end
218
+ @transport_method = transport_method
219
+ end
220
+
221
+ # Checks equality by comparing each attribute.
222
+ # @param [Object] Object to be compared
223
+ def ==(o)
224
+ return true if self.equal?(o)
225
+ self.class == o.class &&
226
+ customer_reference_no == o.customer_reference_no &&
227
+ transport_method == o.transport_method &&
228
+ requested_date == o.requested_date &&
229
+ receive_to_location == o.receive_to_location &&
230
+ inventory_status_code == o.inventory_status_code &&
231
+ reference_no == o.reference_no &&
232
+ first_name == o.first_name &&
233
+ last_name == o.last_name &&
234
+ company == o.company &&
235
+ address == o.address &&
236
+ address2 == o.address2 &&
237
+ city == o.city &&
238
+ state == o.state &&
239
+ zip_code == o.zip_code &&
240
+ phone_number == o.phone_number &&
241
+ email_address == o.email_address &&
242
+ special_instruction == o.special_instruction
243
+ end
244
+
245
+ # @see the `==` method
246
+ # @param [Object] Object to be compared
247
+ def eql?(o)
248
+ self == o
249
+ end
250
+
251
+ # Calculates hash code according to all attributes.
252
+ # @return [Fixnum] Hash code
253
+ def hash
254
+ [customer_reference_no, transport_method, requested_date, receive_to_location, inventory_status_code, reference_no, first_name, last_name, company, address, address2, city, state, zip_code, phone_number, email_address, special_instruction].hash
255
+ end
256
+
257
+ # Builds the object from hash
258
+ # @param [Hash] attributes Model attributes in the form of hash
259
+ # @return [Object] Returns the model itself
260
+ def build_from_hash(attributes)
261
+ return nil unless attributes.is_a?(Hash)
262
+ self.class.swagger_types.each_pair do |key, type|
263
+ if type =~ /\AArray<(.*)>/i
264
+ # check to ensure the input is an array given that the the attribute
265
+ # is documented as an array but the input is not
266
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
267
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
268
+ end
269
+ elsif !attributes[self.class.attribute_map[key]].nil?
270
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
271
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
272
+ end
273
+
274
+ self
275
+ end
276
+
277
+ # Deserializes the data based on type
278
+ # @param string type Data type
279
+ # @param string value Value to be deserialized
280
+ # @return [Object] Deserialized data
281
+ def _deserialize(type, value)
282
+ case type.to_sym
283
+ when :DateTime
284
+ DateTime.parse(value)
285
+ when :Date
286
+ Date.parse(value)
287
+ when :String
288
+ value.to_s
289
+ when :Integer
290
+ value.to_i
291
+ when :Float
292
+ value.to_f
293
+ when :BOOLEAN
294
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
295
+ true
296
+ else
297
+ false
298
+ end
299
+ when :Object
300
+ # generic object (usually a Hash), return directly
301
+ value
302
+ when /\AArray<(?<inner_type>.+)>\z/
303
+ inner_type = Regexp.last_match[:inner_type]
304
+ value.map { |v| _deserialize(inner_type, v) }
305
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
306
+ k_type = Regexp.last_match[:k_type]
307
+ v_type = Regexp.last_match[:v_type]
308
+ {}.tap do |hash|
309
+ value.each do |k, v|
310
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
311
+ end
312
+ end
313
+ else # model
314
+ temp_model = WineShipping.const_get(type).new
315
+ temp_model.build_from_hash(value)
316
+ end
317
+ end
318
+
319
+ # Returns the string representation of the object
320
+ # @return [String] String presentation of the object
321
+ def to_s
322
+ to_hash.to_s
323
+ end
324
+
325
+ # to_body is an alias to to_hash (backward compatibility)
326
+ # @return [Hash] Returns the object in the form of hash
327
+ def to_body
328
+ to_hash
329
+ end
330
+
331
+ # Returns the object in the form of hash
332
+ # @return [Hash] Returns the object in the form of hash
333
+ def to_hash
334
+ hash = {}
335
+ self.class.attribute_map.each_pair do |attr, param|
336
+ value = self.send(attr)
337
+ next if value.nil?
338
+ hash[param] = _to_hash(value)
339
+ end
340
+ hash
341
+ end
342
+
343
+ # Outputs non-array value in the form of hash
344
+ # For object, use to_hash. Otherwise, just return the value
345
+ # @param [Object] value Any valid value
346
+ # @return [Hash] Returns the value in the form of hash
347
+ def _to_hash(value)
348
+ if value.is_a?(Array)
349
+ value.compact.map { |v| _to_hash(v) }
350
+ elsif value.is_a?(Hash)
351
+ {}.tap do |hash|
352
+ value.each { |k, v| hash[k] = _to_hash(v) }
353
+ end
354
+ elsif value.respond_to? :to_hash
355
+ value.to_hash
356
+ else
357
+ value
358
+ end
359
+ end
360
+ end
361
+ end
@@ -0,0 +1,201 @@
1
+ =begin
2
+ #API from Wineshipping
3
+
4
+ #Wineshipping API is a programmatically consumable service or an Application Programming Interface (API) platform designed to enable Wineshipping LLC's client applications to natively transmit and manage their order, view inventory, track shipments etc.<br /><br />In order to access API operations request a UserKey and Password from Wineshipping. For any questions please contact Wineshipping Helpdesk at <a href='mailto:IT-Help@wineshipping.com?Subject=API from Wineshipping'>IT-Help@wineshipping.com</a>.
5
+
6
+ OpenAPI spec version: V3
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.7
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module WineShipping
16
+ class PurchaseOrderItemInfo
17
+ attr_accessor :item_no
18
+
19
+ attr_accessor :item_description
20
+
21
+ attr_accessor :item_quantity
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'item_no' => :'ItemNo',
27
+ :'item_description' => :'ItemDescription',
28
+ :'item_quantity' => :'ItemQuantity'
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.swagger_types
34
+ {
35
+ :'item_no' => :'String',
36
+ :'item_description' => :'String',
37
+ :'item_quantity' => :'Integer'
38
+ }
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ return unless attributes.is_a?(Hash)
45
+
46
+ # convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
48
+
49
+ if attributes.has_key?(:'ItemNo')
50
+ self.item_no = attributes[:'ItemNo']
51
+ end
52
+
53
+ if attributes.has_key?(:'ItemDescription')
54
+ self.item_description = attributes[:'ItemDescription']
55
+ end
56
+
57
+ if attributes.has_key?(:'ItemQuantity')
58
+ self.item_quantity = attributes[:'ItemQuantity']
59
+ end
60
+ end
61
+
62
+ # Show invalid properties with the reasons. Usually used together with valid?
63
+ # @return Array for valid properties with the reasons
64
+ def list_invalid_properties
65
+ invalid_properties = Array.new
66
+ invalid_properties
67
+ end
68
+
69
+ # Check to see if the all the properties in the model are valid
70
+ # @return true if the model is valid
71
+ def valid?
72
+ true
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(o)
78
+ return true if self.equal?(o)
79
+ self.class == o.class &&
80
+ item_no == o.item_no &&
81
+ item_description == o.item_description &&
82
+ item_quantity == o.item_quantity
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(o)
88
+ self == o
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Fixnum] Hash code
93
+ def hash
94
+ [item_no, item_description, item_quantity].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def build_from_hash(attributes)
101
+ return nil unless attributes.is_a?(Hash)
102
+ self.class.swagger_types.each_pair do |key, type|
103
+ if type =~ /\AArray<(.*)>/i
104
+ # check to ensure the input is an array given that the the attribute
105
+ # is documented as an array but the input is not
106
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
107
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
108
+ end
109
+ elsif !attributes[self.class.attribute_map[key]].nil?
110
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
111
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
112
+ end
113
+
114
+ self
115
+ end
116
+
117
+ # Deserializes the data based on type
118
+ # @param string type Data type
119
+ # @param string value Value to be deserialized
120
+ # @return [Object] Deserialized data
121
+ def _deserialize(type, value)
122
+ case type.to_sym
123
+ when :DateTime
124
+ DateTime.parse(value)
125
+ when :Date
126
+ Date.parse(value)
127
+ when :String
128
+ value.to_s
129
+ when :Integer
130
+ value.to_i
131
+ when :Float
132
+ value.to_f
133
+ when :BOOLEAN
134
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
135
+ true
136
+ else
137
+ false
138
+ end
139
+ when :Object
140
+ # generic object (usually a Hash), return directly
141
+ value
142
+ when /\AArray<(?<inner_type>.+)>\z/
143
+ inner_type = Regexp.last_match[:inner_type]
144
+ value.map { |v| _deserialize(inner_type, v) }
145
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
146
+ k_type = Regexp.last_match[:k_type]
147
+ v_type = Regexp.last_match[:v_type]
148
+ {}.tap do |hash|
149
+ value.each do |k, v|
150
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
151
+ end
152
+ end
153
+ else # model
154
+ temp_model = WineShipping.const_get(type).new
155
+ temp_model.build_from_hash(value)
156
+ end
157
+ end
158
+
159
+ # Returns the string representation of the object
160
+ # @return [String] String presentation of the object
161
+ def to_s
162
+ to_hash.to_s
163
+ end
164
+
165
+ # to_body is an alias to to_hash (backward compatibility)
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_body
168
+ to_hash
169
+ end
170
+
171
+ # Returns the object in the form of hash
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_hash
174
+ hash = {}
175
+ self.class.attribute_map.each_pair do |attr, param|
176
+ value = self.send(attr)
177
+ next if value.nil?
178
+ hash[param] = _to_hash(value)
179
+ end
180
+ hash
181
+ end
182
+
183
+ # Outputs non-array value in the form of hash
184
+ # For object, use to_hash. Otherwise, just return the value
185
+ # @param [Object] value Any valid value
186
+ # @return [Hash] Returns the value in the form of hash
187
+ def _to_hash(value)
188
+ if value.is_a?(Array)
189
+ value.compact.map { |v| _to_hash(v) }
190
+ elsif value.is_a?(Hash)
191
+ {}.tap do |hash|
192
+ value.each { |k, v| hash[k] = _to_hash(v) }
193
+ end
194
+ elsif value.respond_to? :to_hash
195
+ value.to_hash
196
+ else
197
+ value
198
+ end
199
+ end
200
+ end
201
+ end