tradenity 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +89 -77
  4. data/lib/tradenity/api_client.rb +408 -0
  5. data/lib/tradenity/api_error.rb +36 -0
  6. data/lib/tradenity/configuration.rb +205 -0
  7. data/lib/tradenity/exceptions.rb +5 -0
  8. data/lib/tradenity/rails/railtie.rb +20 -20
  9. data/lib/tradenity/resources/address.rb +729 -0
  10. data/lib/tradenity/resources/braintree_gateway.rb +804 -0
  11. data/lib/tradenity/resources/brand.rb +732 -0
  12. data/lib/tradenity/resources/cancel_operation.rb +675 -0
  13. data/lib/tradenity/resources/cart_settings.rb +219 -0
  14. data/lib/tradenity/resources/cash_on_delivery_payment.rb +746 -0
  15. data/lib/tradenity/resources/category.rb +763 -0
  16. data/lib/tradenity/resources/collection.rb +734 -0
  17. data/lib/tradenity/resources/contact_info.rb +306 -0
  18. data/lib/tradenity/resources/countries_geo_zone.rb +739 -0
  19. data/lib/tradenity/resources/country.rb +803 -0
  20. data/lib/tradenity/resources/coupon.rb +454 -0
  21. data/lib/tradenity/resources/credit_card_payment.rb +803 -0
  22. data/lib/tradenity/resources/currency.rb +762 -0
  23. data/lib/tradenity/resources/customer.rb +816 -0
  24. data/lib/tradenity/resources/customer_group.rb +723 -0
  25. data/lib/tradenity/resources/dimensions.rb +263 -0
  26. data/lib/tradenity/resources/discount_coupon.rb +811 -0
  27. data/lib/tradenity/resources/discount_promotion.rb +784 -0
  28. data/lib/tradenity/resources/fixed_rate_shipping.rb +837 -0
  29. data/lib/tradenity/resources/free_item_coupon.rb +793 -0
  30. data/lib/tradenity/resources/free_shipping.rb +806 -0
  31. data/lib/tradenity/resources/free_shipping_coupon.rb +788 -0
  32. data/lib/tradenity/resources/free_shipping_promotion.rb +744 -0
  33. data/lib/tradenity/resources/gateway.rb +435 -0
  34. data/lib/tradenity/resources/general_settings.rb +206 -0
  35. data/lib/tradenity/resources/geo_zone.rb +406 -0
  36. data/lib/tradenity/resources/instance_meta.rb +182 -0
  37. data/lib/tradenity/resources/inventory_settings.rb +197 -0
  38. data/lib/tradenity/resources/items_selector.rb +270 -0
  39. data/lib/tradenity/resources/line_item.rb +347 -0
  40. data/lib/tradenity/resources/mail_server_settings.rb +221 -0
  41. data/lib/tradenity/resources/measurement_settings.rb +253 -0
  42. data/lib/tradenity/resources/option.rb +787 -0
  43. data/lib/tradenity/resources/option_set.rb +734 -0
  44. data/lib/tradenity/resources/option_value.rb +680 -0
  45. data/lib/tradenity/resources/order.rb +929 -0
  46. data/lib/tradenity/resources/order_line_item.rb +777 -0
  47. data/lib/tradenity/resources/paging.rb +38 -0
  48. data/lib/tradenity/resources/payment.rb +429 -0
  49. data/lib/tradenity/resources/payment_card.rb +847 -0
  50. data/lib/tradenity/resources/payment_settings.rb +201 -0
  51. data/lib/tradenity/resources/payment_source.rb +392 -0
  52. data/lib/tradenity/resources/payment_token.rb +723 -0
  53. data/lib/tradenity/resources/payment_transaction.rb +740 -0
  54. data/lib/tradenity/resources/photo.rb +341 -0
  55. data/lib/tradenity/resources/product.rb +1156 -0
  56. data/lib/tradenity/resources/promotion.rb +427 -0
  57. data/lib/tradenity/resources/refund_operation.rb +358 -0
  58. data/lib/tradenity/resources/refund_transaction.rb +730 -0
  59. data/lib/tradenity/resources/return_line_item.rb +781 -0
  60. data/lib/tradenity/resources/return_operation.rb +686 -0
  61. data/lib/tradenity/resources/return_settings.rb +255 -0
  62. data/lib/tradenity/resources/shipping_method.rb +530 -0
  63. data/lib/tradenity/resources/shopping_cart.rb +647 -0
  64. data/lib/tradenity/resources/state.rb +675 -0
  65. data/lib/tradenity/resources/states_geo_zone.rb +748 -0
  66. data/lib/tradenity/resources/store_credit.rb +686 -0
  67. data/lib/tradenity/resources/store_credit_payment.rb +764 -0
  68. data/lib/tradenity/resources/store_credit_transaction.rb +730 -0
  69. data/lib/tradenity/resources/store_profile.rb +532 -0
  70. data/lib/tradenity/resources/stripe_gateway.rb +804 -0
  71. data/lib/tradenity/resources/table_rate_rule.rb +712 -0
  72. data/lib/tradenity/resources/table_rate_shipping.rb +834 -0
  73. data/lib/tradenity/resources/tax_class.rb +723 -0
  74. data/lib/tradenity/resources/tax_rate.rb +845 -0
  75. data/lib/tradenity/resources/tax_settings.rb +231 -0
  76. data/lib/tradenity/resources/test_gateway.rb +804 -0
  77. data/lib/tradenity/resources/transaction.rb +523 -0
  78. data/lib/tradenity/resources/utils.rb +7 -0
  79. data/lib/tradenity/resources/variant.rb +877 -0
  80. data/lib/tradenity/resources/web_hooks.rb +262 -0
  81. data/lib/tradenity/resources/weight.rb +235 -0
  82. data/lib/tradenity/resources/wish_list.rb +686 -0
  83. data/lib/tradenity/resources/zip_codes_geo_zone.rb +755 -0
  84. data/lib/tradenity/token_holder.rb +22 -0
  85. data/lib/tradenity/version.rb +13 -3
  86. data/lib/tradenity.rb +117 -7
  87. data/tradenity.gemspec +35 -30
  88. metadata +200 -34
  89. data/lib/tradenity/api.rb +0 -17
  90. data/lib/tradenity/error/exceptions.rb +0 -52
  91. data/lib/tradenity/error/message.rb +0 -38
  92. data/lib/tradenity/http/client.rb +0 -130
  93. data/lib/tradenity/model/base.rb +0 -100
  94. data/lib/tradenity/model/entities.rb +0 -390
  95. data/lib/tradenity/model/paging.rb +0 -23
@@ -0,0 +1,347 @@
1
+ =begin
2
+ #Tradenity API
3
+
4
+ #Tradenity eCommerce Rest API
5
+
6
+ Contact: support@tradenity.com
7
+ Generated by: https://github.com/tradenity
8
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module Tradenity
14
+ class LineItem
15
+
16
+ def id=(id)
17
+ @id = id
18
+ end
19
+
20
+ def id
21
+ if instance_variable_defined?('@id') && @id != nil
22
+ @id
23
+ elsif __meta && __meta.href != nil
24
+ @id = __meta.href.split('/')[-1]
25
+ @id
26
+ else
27
+ nil
28
+ end
29
+ end
30
+
31
+ attr_accessor :__meta
32
+
33
+ attr_accessor :created_at
34
+
35
+ attr_accessor :updated_at
36
+
37
+ attr_accessor :unit_price
38
+
39
+ attr_accessor :quantity
40
+
41
+ attr_accessor :product
42
+
43
+ attr_accessor :taxes
44
+
45
+ attr_accessor :promotions
46
+
47
+ attr_accessor :subtotal
48
+
49
+ attr_accessor :total
50
+
51
+ attr_accessor :shipping_amount
52
+
53
+ attr_accessor :tax_amount
54
+
55
+ attr_accessor :discount_amount
56
+
57
+ # Attribute mapping from ruby-style variable name to JSON key.
58
+ def self.attribute_map
59
+ {
60
+ :'id' => :'id',
61
+ :'__meta' => :'__meta',
62
+ :'created_at' => :'createdAt',
63
+ :'updated_at' => :'updatedAt',
64
+ :'unit_price' => :'unitPrice',
65
+ :'quantity' => :'quantity',
66
+ :'product' => :'product',
67
+ :'taxes' => :'taxes',
68
+ :'promotions' => :'promotions',
69
+ :'subtotal' => :'subtotal',
70
+ :'total' => :'total',
71
+ :'shipping_amount' => :'shippingAmount',
72
+ :'tax_amount' => :'taxAmount',
73
+ :'discount_amount' => :'discountAmount'
74
+ }
75
+ end
76
+
77
+ # Attribute type mapping.
78
+ def self.swagger_types
79
+ {
80
+ :'id' => :'String',
81
+ :'__meta' => :'InstanceMeta',
82
+ :'created_at' => :'DateTime',
83
+ :'updated_at' => :'DateTime',
84
+ :'unit_price' => :'Integer',
85
+ :'quantity' => :'Integer',
86
+ :'product' => :'Product',
87
+ :'taxes' => :'Array<TaxRate>',
88
+ :'promotions' => :'Array<Promotion>',
89
+ :'subtotal' => :'Integer',
90
+ :'total' => :'Integer',
91
+ :'shipping_amount' => :'Integer',
92
+ :'tax_amount' => :'Integer',
93
+ :'discount_amount' => :'Integer'
94
+ }
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ return unless attributes.is_a?(Hash)
101
+
102
+ # convert string to symbol for hash key
103
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
104
+ if attributes.has_key?(:'id')
105
+ self.id = attributes[:'id']
106
+ end
107
+
108
+ if attributes.has_key?(:'__meta')
109
+ self.__meta = attributes[:'__meta']
110
+ end
111
+
112
+ if attributes.has_key?(:'createdAt')
113
+ self.created_at = attributes[:'createdAt']
114
+ end
115
+ if attributes.has_key?(:'created_at')
116
+ self.created_at = attributes[:'created_at']
117
+ end
118
+
119
+ if attributes.has_key?(:'updatedAt')
120
+ self.updated_at = attributes[:'updatedAt']
121
+ end
122
+ if attributes.has_key?(:'updated_at')
123
+ self.updated_at = attributes[:'updated_at']
124
+ end
125
+
126
+ if attributes.has_key?(:'unitPrice')
127
+ self.unit_price = attributes[:'unitPrice']
128
+ end
129
+ if attributes.has_key?(:'unit_price')
130
+ self.unit_price = attributes[:'unit_price']
131
+ end
132
+
133
+ if attributes.has_key?(:'quantity')
134
+ self.quantity = attributes[:'quantity']
135
+ end
136
+
137
+ if attributes.has_key?(:'product')
138
+ self.product = attributes[:'product']
139
+ end
140
+
141
+ if attributes.has_key?(:'taxes')
142
+ if (value = attributes[:'taxes']).is_a?(Array)
143
+ self.taxes = value
144
+ end
145
+ end
146
+
147
+ if attributes.has_key?(:'promotions')
148
+ if (value = attributes[:'promotions']).is_a?(Array)
149
+ self.promotions = value
150
+ end
151
+ end
152
+
153
+ if attributes.has_key?(:'subtotal')
154
+ self.subtotal = attributes[:'subtotal']
155
+ end
156
+
157
+ if attributes.has_key?(:'total')
158
+ self.total = attributes[:'total']
159
+ end
160
+
161
+ if attributes.has_key?(:'shippingAmount')
162
+ self.shipping_amount = attributes[:'shippingAmount']
163
+ end
164
+ if attributes.has_key?(:'shipping_amount')
165
+ self.shipping_amount = attributes[:'shipping_amount']
166
+ end
167
+
168
+ if attributes.has_key?(:'taxAmount')
169
+ self.tax_amount = attributes[:'taxAmount']
170
+ end
171
+ if attributes.has_key?(:'tax_amount')
172
+ self.tax_amount = attributes[:'tax_amount']
173
+ end
174
+
175
+ if attributes.has_key?(:'discountAmount')
176
+ self.discount_amount = attributes[:'discountAmount']
177
+ end
178
+ if attributes.has_key?(:'discount_amount')
179
+ self.discount_amount = attributes[:'discount_amount']
180
+ end
181
+ end
182
+
183
+ # Show invalid properties with the reasons. Usually used together with valid?
184
+ # @return Array for valid properties with the reasons
185
+ def list_invalid_properties
186
+ invalid_properties = Array.new
187
+ if @unit_price.nil?
188
+ invalid_properties.push('invalid value for "unit_price", unit_price cannot be nil.')
189
+ end
190
+
191
+ if @quantity.nil?
192
+ invalid_properties.push('invalid value for "quantity", quantity cannot be nil.')
193
+ end
194
+
195
+ if @product.nil?
196
+ invalid_properties.push('invalid value for "product", product cannot be nil.')
197
+ end
198
+
199
+ invalid_properties
200
+ end
201
+
202
+ # Check to see if the all the properties in the model are valid
203
+ # @return true if the model is valid
204
+ def valid?
205
+ return false if @unit_price.nil?
206
+ return false if @quantity.nil?
207
+ return false if @product.nil?
208
+ true
209
+ end
210
+
211
+ # Checks equality by comparing each attribute.
212
+ # @param [Object] Object to be compared
213
+ def ==(o)
214
+ return true if self.equal?(o)
215
+ self.class == o.class &&
216
+ __meta == o.__meta &&
217
+ created_at == o.created_at &&
218
+ updated_at == o.updated_at &&
219
+ unit_price == o.unit_price &&
220
+ quantity == o.quantity &&
221
+ product == o.product &&
222
+ taxes == o.taxes &&
223
+ promotions == o.promotions &&
224
+ subtotal == o.subtotal &&
225
+ total == o.total &&
226
+ shipping_amount == o.shipping_amount &&
227
+ tax_amount == o.tax_amount &&
228
+ discount_amount == o.discount_amount
229
+ end
230
+
231
+ # @see the `==` method
232
+ # @param [Object] Object to be compared
233
+ def eql?(o)
234
+ self == o
235
+ end
236
+
237
+ # Calculates hash code according to all attributes.
238
+ # @return [Fixnum] Hash code
239
+ def hash
240
+ [__meta, created_at, updated_at, unit_price, quantity, product, taxes, promotions, subtotal, total, shipping_amount, tax_amount, discount_amount].hash
241
+ end
242
+
243
+ # Builds the object from hash
244
+ # @param [Hash] attributes Model attributes in the form of hash
245
+ # @return [Object] Returns the model itself
246
+ def build_from_hash(attributes)
247
+ return nil unless attributes.is_a?(Hash)
248
+ self.class.swagger_types.each_pair do |key, type|
249
+ if type =~ /\AArray<(.*)>/i
250
+ # check to ensure the input is an array given that the the attribute
251
+ # is documented as an array but the input is not
252
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
253
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
254
+ end
255
+ elsif !attributes[self.class.attribute_map[key]].nil?
256
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
257
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
258
+ end
259
+
260
+ self
261
+ end
262
+
263
+ # Deserializes the data based on type
264
+ # @param string type Data type
265
+ # @param string value Value to be deserialized
266
+ # @return [Object] Deserialized data
267
+ def _deserialize(type, value)
268
+ case type.to_sym
269
+ when :DateTime
270
+ DateTime.parse(value)
271
+ when :Date
272
+ Date.parse(value)
273
+ when :String
274
+ value.to_s
275
+ when :Integer
276
+ value.to_i
277
+ when :Float
278
+ value.to_f
279
+ when :BOOLEAN
280
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
281
+ true
282
+ else
283
+ false
284
+ end
285
+ when :Object
286
+ # generic object (usually a Hash), return directly
287
+ value
288
+ when /\AArray<(?<inner_type>.+)>\z/
289
+ inner_type = Regexp.last_match[:inner_type]
290
+ value.map { |v| _deserialize(inner_type, v) }
291
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
292
+ k_type = Regexp.last_match[:k_type]
293
+ v_type = Regexp.last_match[:v_type]
294
+ {}.tap do |hash|
295
+ value.each do |k, v|
296
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
297
+ end
298
+ end
299
+ else # model
300
+ temp_model = Tradenity.const_get(type).new
301
+ temp_model.build_from_hash(value)
302
+ end
303
+ end
304
+
305
+ # Returns the string representation of the object
306
+ # @return [String] String presentation of the object
307
+ def to_s
308
+ to_hash.to_s
309
+ end
310
+
311
+ # to_body is an alias to to_hash (backward compatibility)
312
+ # @return [Hash] Returns the object in the form of hash
313
+ def to_body
314
+ to_hash
315
+ end
316
+
317
+ # Returns the object in the form of hash
318
+ # @return [Hash] Returns the object in the form of hash
319
+ def to_hash
320
+ hash = {}
321
+ self.class.attribute_map.each_pair do |attr, param|
322
+ value = self.send(attr)
323
+ next if value.nil?
324
+ hash[param] = _to_hash(value)
325
+ end
326
+ hash
327
+ end
328
+
329
+ # Outputs non-array value in the form of hash
330
+ # For object, use to_hash. Otherwise, just return the value
331
+ # @param [Object] value Any valid value
332
+ # @return [Hash] Returns the value in the form of hash
333
+ def _to_hash(value)
334
+ if value.is_a?(Array)
335
+ value.compact.map { |v| _to_hash(v) }
336
+ elsif value.is_a?(Hash)
337
+ {}.tap do |hash|
338
+ value.each { |k, v| hash[k] = _to_hash(v) }
339
+ end
340
+ elsif value.respond_to? :to_hash
341
+ value.to_hash
342
+ else
343
+ value
344
+ end
345
+ end
346
+ end
347
+ end
@@ -0,0 +1,221 @@
1
+ =begin
2
+ #Tradenity API
3
+
4
+ #Tradenity eCommerce Rest API
5
+
6
+ Contact: support@tradenity.com
7
+ Generated by: https://github.com/tradenity
8
+
9
+ =end
10
+
11
+ require 'date'
12
+
13
+ module Tradenity
14
+ class MailServerSettings
15
+
16
+ attr_accessor :sender_email
17
+
18
+ attr_accessor :host
19
+
20
+ attr_accessor :port
21
+
22
+ attr_accessor :username
23
+
24
+ attr_accessor :password
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'sender_email' => :'senderEmail',
30
+ :'host' => :'host',
31
+ :'port' => :'port',
32
+ :'username' => :'username',
33
+ :'password' => :'password'
34
+ }
35
+ end
36
+
37
+ # Attribute type mapping.
38
+ def self.swagger_types
39
+ {
40
+ :'sender_email' => :'String',
41
+ :'host' => :'String',
42
+ :'port' => :'Integer',
43
+ :'username' => :'String',
44
+ :'password' => :'String'
45
+ }
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ return unless attributes.is_a?(Hash)
52
+
53
+ # convert string to symbol for hash key
54
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
55
+
56
+ if attributes.has_key?(:'senderEmail')
57
+ self.sender_email = attributes[:'senderEmail']
58
+ end
59
+ if attributes.has_key?(:'sender_email')
60
+ self.sender_email = attributes[:'sender_email']
61
+ end
62
+
63
+ if attributes.has_key?(:'host')
64
+ self.host = attributes[:'host']
65
+ end
66
+
67
+ if attributes.has_key?(:'port')
68
+ self.port = attributes[:'port']
69
+ end
70
+
71
+ if attributes.has_key?(:'username')
72
+ self.username = attributes[:'username']
73
+ end
74
+
75
+ if attributes.has_key?(:'password')
76
+ self.password = attributes[:'password']
77
+ end
78
+ end
79
+
80
+ # Show invalid properties with the reasons. Usually used together with valid?
81
+ # @return Array for valid properties with the reasons
82
+ def list_invalid_properties
83
+ invalid_properties = Array.new
84
+ invalid_properties
85
+ end
86
+
87
+ # Check to see if the all the properties in the model are valid
88
+ # @return true if the model is valid
89
+ def valid?
90
+ true
91
+ end
92
+
93
+ # Checks equality by comparing each attribute.
94
+ # @param [Object] Object to be compared
95
+ def ==(o)
96
+ return true if self.equal?(o)
97
+ self.class == o.class &&
98
+ sender_email == o.sender_email &&
99
+ host == o.host &&
100
+ port == o.port &&
101
+ username == o.username &&
102
+ password == o.password
103
+ end
104
+
105
+ # @see the `==` method
106
+ # @param [Object] Object to be compared
107
+ def eql?(o)
108
+ self == o
109
+ end
110
+
111
+ # Calculates hash code according to all attributes.
112
+ # @return [Fixnum] Hash code
113
+ def hash
114
+ [sender_email, host, port, username, password].hash
115
+ end
116
+
117
+ # Builds the object from hash
118
+ # @param [Hash] attributes Model attributes in the form of hash
119
+ # @return [Object] Returns the model itself
120
+ def build_from_hash(attributes)
121
+ return nil unless attributes.is_a?(Hash)
122
+ self.class.swagger_types.each_pair do |key, type|
123
+ if type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the the attribute
125
+ # is documented as an array but the input is not
126
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
127
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
128
+ end
129
+ elsif !attributes[self.class.attribute_map[key]].nil?
130
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
131
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
132
+ end
133
+
134
+ self
135
+ end
136
+
137
+ # Deserializes the data based on type
138
+ # @param string type Data type
139
+ # @param string value Value to be deserialized
140
+ # @return [Object] Deserialized data
141
+ def _deserialize(type, value)
142
+ case type.to_sym
143
+ when :DateTime
144
+ DateTime.parse(value)
145
+ when :Date
146
+ Date.parse(value)
147
+ when :String
148
+ value.to_s
149
+ when :Integer
150
+ value.to_i
151
+ when :Float
152
+ value.to_f
153
+ when :BOOLEAN
154
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
155
+ true
156
+ else
157
+ false
158
+ end
159
+ when :Object
160
+ # generic object (usually a Hash), return directly
161
+ value
162
+ when /\AArray<(?<inner_type>.+)>\z/
163
+ inner_type = Regexp.last_match[:inner_type]
164
+ value.map { |v| _deserialize(inner_type, v) }
165
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
166
+ k_type = Regexp.last_match[:k_type]
167
+ v_type = Regexp.last_match[:v_type]
168
+ {}.tap do |hash|
169
+ value.each do |k, v|
170
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
171
+ end
172
+ end
173
+ else # model
174
+ temp_model = Tradenity.const_get(type).new
175
+ temp_model.build_from_hash(value)
176
+ end
177
+ end
178
+
179
+ # Returns the string representation of the object
180
+ # @return [String] String presentation of the object
181
+ def to_s
182
+ to_hash.to_s
183
+ end
184
+
185
+ # to_body is an alias to to_hash (backward compatibility)
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_body
188
+ to_hash
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = self.send(attr)
197
+ next if value.nil?
198
+ hash[param] = _to_hash(value)
199
+ end
200
+ hash
201
+ end
202
+
203
+ # Outputs non-array value in the form of hash
204
+ # For object, use to_hash. Otherwise, just return the value
205
+ # @param [Object] value Any valid value
206
+ # @return [Hash] Returns the value in the form of hash
207
+ def _to_hash(value)
208
+ if value.is_a?(Array)
209
+ value.compact.map { |v| _to_hash(v) }
210
+ elsif value.is_a?(Hash)
211
+ {}.tap do |hash|
212
+ value.each { |k, v| hash[k] = _to_hash(v) }
213
+ end
214
+ elsif value.respond_to? :to_hash
215
+ value.to_hash
216
+ else
217
+ value
218
+ end
219
+ end
220
+ end
221
+ end