noths 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +69 -0
  4. data/README.md +149 -0
  5. data/Rakefile +8 -0
  6. data/bin/generate_gem +18 -0
  7. data/bin/refresh_schemas +94 -0
  8. data/docs/AcceptanceBulkModel.md +11 -0
  9. data/docs/Currency.md +11 -0
  10. data/docs/DeclineBulkModel.md +9 -0
  11. data/docs/DeliveryAddress.md +13 -0
  12. data/docs/DeliveryService.md +9 -0
  13. data/docs/DeliveryZone.md +9 -0
  14. data/docs/DispatchBulkModel.md +12 -0
  15. data/docs/DispatchNotesBulkModel.md +8 -0
  16. data/docs/Enquiry.md +10 -0
  17. data/docs/EnquiryMessage.md +8 -0
  18. data/docs/Error.md +9 -0
  19. data/docs/Financials.md +25 -0
  20. data/docs/FinancialsDetails.md +10 -0
  21. data/docs/ImageUrl.md +13 -0
  22. data/docs/Item.md +15 -0
  23. data/docs/ItemFinancials.md +13 -0
  24. data/docs/Link.md +10 -0
  25. data/docs/ManualPayment.md +11 -0
  26. data/docs/Money.md +9 -0
  27. data/docs/Order.md +53 -0
  28. data/docs/OrderDetail.md +9 -0
  29. data/docs/OrderDetailsBulkModel.md +8 -0
  30. data/docs/OrderIndex.md +10 -0
  31. data/docs/OrderRefund.md +8 -0
  32. data/docs/OrdersApi.md +796 -0
  33. data/docs/Product.md +12 -0
  34. data/docs/ProductOption.md +9 -0
  35. data/docs/RefundResponse.md +10 -0
  36. data/docs/RefundsApi.md +69 -0
  37. data/docs/SearchResultMeta.md +9 -0
  38. data/docs/User.md +10 -0
  39. data/lib/noths.rb +70 -0
  40. data/lib/noths/api/orders_api.rb +819 -0
  41. data/lib/noths/api/refunds_api.rb +88 -0
  42. data/lib/noths/api_client.rb +389 -0
  43. data/lib/noths/api_error.rb +38 -0
  44. data/lib/noths/configuration.rb +209 -0
  45. data/lib/noths/models/acceptance_bulk_model.rb +233 -0
  46. data/lib/noths/models/currency.rb +235 -0
  47. data/lib/noths/models/decline_bulk_model.rb +208 -0
  48. data/lib/noths/models/delivery_address.rb +263 -0
  49. data/lib/noths/models/delivery_service.rb +207 -0
  50. data/lib/noths/models/delivery_zone.rb +207 -0
  51. data/lib/noths/models/dispatch_bulk_model.rb +236 -0
  52. data/lib/noths/models/dispatch_notes_bulk_model.rb +194 -0
  53. data/lib/noths/models/enquiry.rb +223 -0
  54. data/lib/noths/models/enquiry_message.rb +193 -0
  55. data/lib/noths/models/error.rb +207 -0
  56. data/lib/noths/models/financials.rb +433 -0
  57. data/lib/noths/models/financials_details.rb +221 -0
  58. data/lib/noths/models/image_url.rb +263 -0
  59. data/lib/noths/models/item.rb +293 -0
  60. data/lib/noths/models/item_financials.rb +263 -0
  61. data/lib/noths/models/link.rb +222 -0
  62. data/lib/noths/models/manual_payment.rb +235 -0
  63. data/lib/noths/models/money.rb +207 -0
  64. data/lib/noths/models/order.rb +812 -0
  65. data/lib/noths/models/order_detail.rb +207 -0
  66. data/lib/noths/models/order_details_bulk_model.rb +194 -0
  67. data/lib/noths/models/order_index.rb +225 -0
  68. data/lib/noths/models/order_refund.rb +193 -0
  69. data/lib/noths/models/product.rb +249 -0
  70. data/lib/noths/models/product_option.rb +207 -0
  71. data/lib/noths/models/refund_response.rb +223 -0
  72. data/lib/noths/models/search_result_meta.rb +207 -0
  73. data/lib/noths/models/user.rb +221 -0
  74. data/lib/noths/version.rb +15 -0
  75. data/noths.gemspec +45 -0
  76. data/schemas/api-docs.json +26 -0
  77. data/schemas/orders.json +2013 -0
  78. data/schemas/refunds.json +128 -0
  79. data/spec/api/orders_api_spec.rb +239 -0
  80. data/spec/api/refunds_api_spec.rb +50 -0
  81. data/spec/api_client_spec.rb +226 -0
  82. data/spec/configuration_spec.rb +42 -0
  83. data/spec/models/acceptance_bulk_model_spec.rb +60 -0
  84. data/spec/models/currency_spec.rb +60 -0
  85. data/spec/models/decline_bulk_model_spec.rb +48 -0
  86. data/spec/models/delivery_address_spec.rb +72 -0
  87. data/spec/models/delivery_service_spec.rb +48 -0
  88. data/spec/models/delivery_zone_spec.rb +48 -0
  89. data/spec/models/dispatch_bulk_model_spec.rb +66 -0
  90. data/spec/models/dispatch_notes_bulk_model_spec.rb +42 -0
  91. data/spec/models/enquiry_message_spec.rb +42 -0
  92. data/spec/models/enquiry_spec.rb +54 -0
  93. data/spec/models/error_spec.rb +48 -0
  94. data/spec/models/financials_details_spec.rb +54 -0
  95. data/spec/models/financials_spec.rb +144 -0
  96. data/spec/models/image_url_spec.rb +72 -0
  97. data/spec/models/item_financials_spec.rb +72 -0
  98. data/spec/models/item_spec.rb +84 -0
  99. data/spec/models/link_spec.rb +54 -0
  100. data/spec/models/manual_payment_spec.rb +60 -0
  101. data/spec/models/money_spec.rb +48 -0
  102. data/spec/models/order_detail_spec.rb +48 -0
  103. data/spec/models/order_details_bulk_model_spec.rb +42 -0
  104. data/spec/models/order_index_spec.rb +54 -0
  105. data/spec/models/order_refund_spec.rb +42 -0
  106. data/spec/models/order_spec.rb +312 -0
  107. data/spec/models/product_option_spec.rb +48 -0
  108. data/spec/models/product_spec.rb +66 -0
  109. data/spec/models/refund_response_spec.rb +54 -0
  110. data/spec/models/search_result_meta_spec.rb +48 -0
  111. data/spec/models/user_spec.rb +54 -0
  112. data/spec/spec_helper.rb +111 -0
  113. data/swagger_config.json +16 -0
  114. metadata +370 -0
@@ -0,0 +1,293 @@
1
+ =begin
2
+ #Noths
3
+
4
+ #www.notonthehighstreet.com API client
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Noths
16
+
17
+ class Item
18
+ attr_accessor :id
19
+
20
+ attr_accessor :item_title
21
+
22
+ attr_accessor :quantity
23
+
24
+ attr_accessor :commission_vat_rate
25
+
26
+ attr_accessor :listing_total_gross
27
+
28
+ attr_accessor :product
29
+
30
+ attr_accessor :options
31
+
32
+ attr_accessor :financials
33
+
34
+
35
+ # Attribute mapping from ruby-style variable name to JSON key.
36
+ def self.attribute_map
37
+ {
38
+ :'id' => :'id',
39
+ :'item_title' => :'item_title',
40
+ :'quantity' => :'quantity',
41
+ :'commission_vat_rate' => :'commission_vat_rate',
42
+ :'listing_total_gross' => :'listing_total_gross',
43
+ :'product' => :'product',
44
+ :'options' => :'options',
45
+ :'financials' => :'financials'
46
+ }
47
+ end
48
+
49
+ # Attribute type mapping.
50
+ def self.swagger_types
51
+ {
52
+ :'id' => :'Integer',
53
+ :'item_title' => :'String',
54
+ :'quantity' => :'Integer',
55
+ :'commission_vat_rate' => :'String',
56
+ :'listing_total_gross' => :'Money',
57
+ :'product' => :'Product',
58
+ :'options' => :'Array<ProductOption>',
59
+ :'financials' => :'ItemFinancials'
60
+ }
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ return unless attributes.is_a?(Hash)
67
+
68
+ # convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
70
+
71
+ if attributes.has_key?(:'id')
72
+ self.id = attributes[:'id']
73
+ end
74
+
75
+ if attributes.has_key?(:'item_title')
76
+ self.item_title = attributes[:'item_title']
77
+ end
78
+
79
+ if attributes.has_key?(:'quantity')
80
+ self.quantity = attributes[:'quantity']
81
+ end
82
+
83
+ if attributes.has_key?(:'commission_vat_rate')
84
+ self.commission_vat_rate = attributes[:'commission_vat_rate']
85
+ end
86
+
87
+ if attributes.has_key?(:'listing_total_gross')
88
+ self.listing_total_gross = attributes[:'listing_total_gross']
89
+ end
90
+
91
+ if attributes.has_key?(:'product')
92
+ self.product = attributes[:'product']
93
+ end
94
+
95
+ if attributes.has_key?(:'options')
96
+ if (value = attributes[:'options']).is_a?(Array)
97
+ self.options = value
98
+ end
99
+ end
100
+
101
+ if attributes.has_key?(:'financials')
102
+ self.financials = attributes[:'financials']
103
+ end
104
+
105
+ end
106
+
107
+ # Show invalid properties with the reasons. Usually used together with valid?
108
+ # @return Array for valid properties with the reasons
109
+ def list_invalid_properties
110
+ invalid_properties = Array.new
111
+ if @id.nil?
112
+ invalid_properties.push("invalid value for 'id', id cannot be nil.")
113
+ end
114
+
115
+ if @item_title.nil?
116
+ invalid_properties.push("invalid value for 'item_title', item_title cannot be nil.")
117
+ end
118
+
119
+ if @quantity.nil?
120
+ invalid_properties.push("invalid value for 'quantity', quantity cannot be nil.")
121
+ end
122
+
123
+ if @commission_vat_rate.nil?
124
+ invalid_properties.push("invalid value for 'commission_vat_rate', commission_vat_rate cannot be nil.")
125
+ end
126
+
127
+ if @listing_total_gross.nil?
128
+ invalid_properties.push("invalid value for 'listing_total_gross', listing_total_gross cannot be nil.")
129
+ end
130
+
131
+ if @product.nil?
132
+ invalid_properties.push("invalid value for 'product', product cannot be nil.")
133
+ end
134
+
135
+ if @options.nil?
136
+ invalid_properties.push("invalid value for 'options', options cannot be nil.")
137
+ end
138
+
139
+ if @financials.nil?
140
+ invalid_properties.push("invalid value for 'financials', financials cannot be nil.")
141
+ end
142
+
143
+ return invalid_properties
144
+ end
145
+
146
+ # Check to see if the all the properties in the model are valid
147
+ # @return true if the model is valid
148
+ def valid?
149
+ return false if @id.nil?
150
+ return false if @item_title.nil?
151
+ return false if @quantity.nil?
152
+ return false if @commission_vat_rate.nil?
153
+ return false if @listing_total_gross.nil?
154
+ return false if @product.nil?
155
+ return false if @options.nil?
156
+ return false if @financials.nil?
157
+ return true
158
+ end
159
+
160
+ # Checks equality by comparing each attribute.
161
+ # @param [Object] Object to be compared
162
+ def ==(o)
163
+ return true if self.equal?(o)
164
+ self.class == o.class &&
165
+ id == o.id &&
166
+ item_title == o.item_title &&
167
+ quantity == o.quantity &&
168
+ commission_vat_rate == o.commission_vat_rate &&
169
+ listing_total_gross == o.listing_total_gross &&
170
+ product == o.product &&
171
+ options == o.options &&
172
+ financials == o.financials
173
+ end
174
+
175
+ # @see the `==` method
176
+ # @param [Object] Object to be compared
177
+ def eql?(o)
178
+ self == o
179
+ end
180
+
181
+ # Calculates hash code according to all attributes.
182
+ # @return [Fixnum] Hash code
183
+ def hash
184
+ [id, item_title, quantity, commission_vat_rate, listing_total_gross, product, options, financials].hash
185
+ end
186
+
187
+ # Builds the object from hash
188
+ # @param [Hash] attributes Model attributes in the form of hash
189
+ # @return [Object] Returns the model itself
190
+ def build_from_hash(attributes)
191
+ return nil unless attributes.is_a?(Hash)
192
+ self.class.swagger_types.each_pair do |key, type|
193
+ if type =~ /\AArray<(.*)>/i
194
+ # check to ensure the input is an array given that the the attribute
195
+ # is documented as an array but the input is not
196
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
197
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
198
+ end
199
+ elsif !attributes[self.class.attribute_map[key]].nil?
200
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
201
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
202
+ end
203
+
204
+ self
205
+ end
206
+
207
+ # Deserializes the data based on type
208
+ # @param string type Data type
209
+ # @param string value Value to be deserialized
210
+ # @return [Object] Deserialized data
211
+ def _deserialize(type, value)
212
+ case type.to_sym
213
+ when :DateTime
214
+ DateTime.parse(value)
215
+ when :Date
216
+ Date.parse(value)
217
+ when :String
218
+ value.to_s
219
+ when :Integer
220
+ value.to_i
221
+ when :Float
222
+ value.to_f
223
+ when :BOOLEAN
224
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
225
+ true
226
+ else
227
+ false
228
+ end
229
+ when :Object
230
+ # generic object (usually a Hash), return directly
231
+ value
232
+ when /\AArray<(?<inner_type>.+)>\z/
233
+ inner_type = Regexp.last_match[:inner_type]
234
+ value.map { |v| _deserialize(inner_type, v) }
235
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
236
+ k_type = Regexp.last_match[:k_type]
237
+ v_type = Regexp.last_match[:v_type]
238
+ {}.tap do |hash|
239
+ value.each do |k, v|
240
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
241
+ end
242
+ end
243
+ else # model
244
+ temp_model = Noths.const_get(type).new
245
+ temp_model.build_from_hash(value)
246
+ end
247
+ end
248
+
249
+ # Returns the string representation of the object
250
+ # @return [String] String presentation of the object
251
+ def to_s
252
+ to_hash.to_s
253
+ end
254
+
255
+ # to_body is an alias to to_hash (backward compatibility)
256
+ # @return [Hash] Returns the object in the form of hash
257
+ def to_body
258
+ to_hash
259
+ end
260
+
261
+ # Returns the object in the form of hash
262
+ # @return [Hash] Returns the object in the form of hash
263
+ def to_hash
264
+ hash = {}
265
+ self.class.attribute_map.each_pair do |attr, param|
266
+ value = self.send(attr)
267
+ next if value.nil?
268
+ hash[param] = _to_hash(value)
269
+ end
270
+ hash
271
+ end
272
+
273
+ # Outputs non-array value in the form of hash
274
+ # For object, use to_hash. Otherwise, just return the value
275
+ # @param [Object] value Any valid value
276
+ # @return [Hash] Returns the value in the form of hash
277
+ def _to_hash(value)
278
+ if value.is_a?(Array)
279
+ value.compact.map{ |v| _to_hash(v) }
280
+ elsif value.is_a?(Hash)
281
+ {}.tap do |hash|
282
+ value.each { |k, v| hash[k] = _to_hash(v) }
283
+ end
284
+ elsif value.respond_to? :to_hash
285
+ value.to_hash
286
+ else
287
+ value
288
+ end
289
+ end
290
+
291
+ end
292
+
293
+ end
@@ -0,0 +1,263 @@
1
+ =begin
2
+ #Noths
3
+
4
+ #www.notonthehighstreet.com API client
5
+
6
+ OpenAPI spec version: 1.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.3.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module Noths
16
+
17
+ class ItemFinancials
18
+ attr_accessor :commission_rate
19
+
20
+ attr_accessor :commission_vat_rate
21
+
22
+ attr_accessor :commission
23
+
24
+ attr_accessor :listing_price
25
+
26
+ attr_accessor :listing_total
27
+
28
+ attr_accessor :listing_discounted_price
29
+
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ :'commission_rate' => :'commission_rate',
35
+ :'commission_vat_rate' => :'commission_vat_rate',
36
+ :'commission' => :'commission',
37
+ :'listing_price' => :'listing_price',
38
+ :'listing_total' => :'listing_total',
39
+ :'listing_discounted_price' => :'listing_discounted_price'
40
+ }
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.swagger_types
45
+ {
46
+ :'commission_rate' => :'Integer',
47
+ :'commission_vat_rate' => :'Integer',
48
+ :'commission' => :'FinancialsDetails',
49
+ :'listing_price' => :'FinancialsDetails',
50
+ :'listing_total' => :'FinancialsDetails',
51
+ :'listing_discounted_price' => :'FinancialsDetails'
52
+ }
53
+ end
54
+
55
+ # Initializes the object
56
+ # @param [Hash] attributes Model attributes in the form of hash
57
+ def initialize(attributes = {})
58
+ return unless attributes.is_a?(Hash)
59
+
60
+ # convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
62
+
63
+ if attributes.has_key?(:'commission_rate')
64
+ self.commission_rate = attributes[:'commission_rate']
65
+ end
66
+
67
+ if attributes.has_key?(:'commission_vat_rate')
68
+ self.commission_vat_rate = attributes[:'commission_vat_rate']
69
+ end
70
+
71
+ if attributes.has_key?(:'commission')
72
+ self.commission = attributes[:'commission']
73
+ end
74
+
75
+ if attributes.has_key?(:'listing_price')
76
+ self.listing_price = attributes[:'listing_price']
77
+ end
78
+
79
+ if attributes.has_key?(:'listing_total')
80
+ self.listing_total = attributes[:'listing_total']
81
+ end
82
+
83
+ if attributes.has_key?(:'listing_discounted_price')
84
+ self.listing_discounted_price = attributes[:'listing_discounted_price']
85
+ end
86
+
87
+ end
88
+
89
+ # Show invalid properties with the reasons. Usually used together with valid?
90
+ # @return Array for valid properties with the reasons
91
+ def list_invalid_properties
92
+ invalid_properties = Array.new
93
+ if @commission_rate.nil?
94
+ invalid_properties.push("invalid value for 'commission_rate', commission_rate cannot be nil.")
95
+ end
96
+
97
+ if @commission_vat_rate.nil?
98
+ invalid_properties.push("invalid value for 'commission_vat_rate', commission_vat_rate cannot be nil.")
99
+ end
100
+
101
+ if @commission.nil?
102
+ invalid_properties.push("invalid value for 'commission', commission cannot be nil.")
103
+ end
104
+
105
+ if @listing_price.nil?
106
+ invalid_properties.push("invalid value for 'listing_price', listing_price cannot be nil.")
107
+ end
108
+
109
+ if @listing_total.nil?
110
+ invalid_properties.push("invalid value for 'listing_total', listing_total cannot be nil.")
111
+ end
112
+
113
+ if @listing_discounted_price.nil?
114
+ invalid_properties.push("invalid value for 'listing_discounted_price', listing_discounted_price cannot be nil.")
115
+ end
116
+
117
+ return invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return false if @commission_rate.nil?
124
+ return false if @commission_vat_rate.nil?
125
+ return false if @commission.nil?
126
+ return false if @listing_price.nil?
127
+ return false if @listing_total.nil?
128
+ return false if @listing_discounted_price.nil?
129
+ return true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ commission_rate == o.commission_rate &&
138
+ commission_vat_rate == o.commission_vat_rate &&
139
+ commission == o.commission &&
140
+ listing_price == o.listing_price &&
141
+ listing_total == o.listing_total &&
142
+ listing_discounted_price == o.listing_discounted_price
143
+ end
144
+
145
+ # @see the `==` method
146
+ # @param [Object] Object to be compared
147
+ def eql?(o)
148
+ self == o
149
+ end
150
+
151
+ # Calculates hash code according to all attributes.
152
+ # @return [Fixnum] Hash code
153
+ def hash
154
+ [commission_rate, commission_vat_rate, commission, listing_price, listing_total, listing_discounted_price].hash
155
+ end
156
+
157
+ # Builds the object from hash
158
+ # @param [Hash] attributes Model attributes in the form of hash
159
+ # @return [Object] Returns the model itself
160
+ def build_from_hash(attributes)
161
+ return nil unless attributes.is_a?(Hash)
162
+ self.class.swagger_types.each_pair do |key, type|
163
+ if type =~ /\AArray<(.*)>/i
164
+ # check to ensure the input is an array given that the the attribute
165
+ # is documented as an array but the input is not
166
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
167
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
168
+ end
169
+ elsif !attributes[self.class.attribute_map[key]].nil?
170
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
171
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
172
+ end
173
+
174
+ self
175
+ end
176
+
177
+ # Deserializes the data based on type
178
+ # @param string type Data type
179
+ # @param string value Value to be deserialized
180
+ # @return [Object] Deserialized data
181
+ def _deserialize(type, value)
182
+ case type.to_sym
183
+ when :DateTime
184
+ DateTime.parse(value)
185
+ when :Date
186
+ Date.parse(value)
187
+ when :String
188
+ value.to_s
189
+ when :Integer
190
+ value.to_i
191
+ when :Float
192
+ value.to_f
193
+ when :BOOLEAN
194
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
195
+ true
196
+ else
197
+ false
198
+ end
199
+ when :Object
200
+ # generic object (usually a Hash), return directly
201
+ value
202
+ when /\AArray<(?<inner_type>.+)>\z/
203
+ inner_type = Regexp.last_match[:inner_type]
204
+ value.map { |v| _deserialize(inner_type, v) }
205
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
206
+ k_type = Regexp.last_match[:k_type]
207
+ v_type = Regexp.last_match[:v_type]
208
+ {}.tap do |hash|
209
+ value.each do |k, v|
210
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
211
+ end
212
+ end
213
+ else # model
214
+ temp_model = Noths.const_get(type).new
215
+ temp_model.build_from_hash(value)
216
+ end
217
+ end
218
+
219
+ # Returns the string representation of the object
220
+ # @return [String] String presentation of the object
221
+ def to_s
222
+ to_hash.to_s
223
+ end
224
+
225
+ # to_body is an alias to to_hash (backward compatibility)
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_body
228
+ to_hash
229
+ end
230
+
231
+ # Returns the object in the form of hash
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_hash
234
+ hash = {}
235
+ self.class.attribute_map.each_pair do |attr, param|
236
+ value = self.send(attr)
237
+ next if value.nil?
238
+ hash[param] = _to_hash(value)
239
+ end
240
+ hash
241
+ end
242
+
243
+ # Outputs non-array value in the form of hash
244
+ # For object, use to_hash. Otherwise, just return the value
245
+ # @param [Object] value Any valid value
246
+ # @return [Hash] Returns the value in the form of hash
247
+ def _to_hash(value)
248
+ if value.is_a?(Array)
249
+ value.compact.map{ |v| _to_hash(v) }
250
+ elsif value.is_a?(Hash)
251
+ {}.tap do |hash|
252
+ value.each { |k, v| hash[k] = _to_hash(v) }
253
+ end
254
+ elsif value.respond_to? :to_hash
255
+ value.to_hash
256
+ else
257
+ value
258
+ end
259
+ end
260
+
261
+ end
262
+
263
+ end