patch_ruby 1.9.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +40 -44
  5. data/Makefile +2 -2
  6. data/lib/patch_ruby/api/estimates_api.rb +33 -25
  7. data/lib/patch_ruby/api/orders_api.rb +21 -16
  8. data/lib/patch_ruby/api/preferences_api.rb +17 -13
  9. data/lib/patch_ruby/api/projects_api.rb +9 -7
  10. data/lib/patch_ruby/api_client.rb +51 -49
  11. data/lib/patch_ruby/api_error.rb +1 -1
  12. data/lib/patch_ruby/configuration.rb +38 -9
  13. data/lib/patch_ruby/models/allocation.rb +21 -11
  14. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +25 -19
  15. data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +26 -21
  16. data/lib/patch_ruby/models/create_flight_estimate_request.rb +323 -0
  17. data/lib/patch_ruby/models/create_mass_estimate_request.rb +22 -13
  18. data/lib/patch_ruby/models/create_order_request.rb +21 -11
  19. data/lib/patch_ruby/models/create_preference_request.rb +21 -11
  20. data/lib/patch_ruby/models/create_shipping_estimate_request.rb +371 -0
  21. data/lib/patch_ruby/models/create_success_response.rb +247 -0
  22. data/lib/patch_ruby/models/create_vehicle_estimate_request.rb +326 -0
  23. data/lib/patch_ruby/models/error_response.rb +22 -13
  24. data/lib/patch_ruby/models/estimate.rb +22 -13
  25. data/lib/patch_ruby/models/estimate_list_response.rb +22 -13
  26. data/lib/patch_ruby/models/estimate_response.rb +22 -13
  27. data/lib/patch_ruby/models/meta_index_object.rb +23 -15
  28. data/lib/patch_ruby/models/order.rb +23 -15
  29. data/lib/patch_ruby/models/order_list_response.rb +22 -13
  30. data/lib/patch_ruby/models/order_response.rb +22 -13
  31. data/lib/patch_ruby/models/photo.rb +21 -11
  32. data/lib/patch_ruby/models/preference.rb +21 -11
  33. data/lib/patch_ruby/models/preference_list_response.rb +22 -13
  34. data/lib/patch_ruby/models/preference_response.rb +22 -13
  35. data/lib/patch_ruby/models/project.rb +24 -17
  36. data/lib/patch_ruby/models/project_list_response.rb +22 -13
  37. data/lib/patch_ruby/models/project_response.rb +22 -13
  38. data/lib/patch_ruby/models/sdg.rb +21 -11
  39. data/lib/patch_ruby/models/standard.rb +21 -11
  40. data/lib/patch_ruby/version.rb +2 -2
  41. data/lib/patch_ruby.rb +5 -1
  42. data/patch_ruby.gemspec +8 -3
  43. data/spec/api_client_spec.rb +34 -13
  44. data/spec/configuration_spec.rb +1 -1
  45. data/spec/integration/estimates_spec.rb +17 -1
  46. data/spec/integration/preferences_spec.rb +1 -1
  47. data/spec/models/create_mass_estimate_request_spec.rb +1 -1
  48. data/spec/models/error_response_spec.rb +1 -1
  49. data/spec/models/estimate_list_response_spec.rb +1 -1
  50. data/spec/models/estimate_response_spec.rb +1 -1
  51. data/spec/models/estimate_spec.rb +1 -1
  52. data/spec/models/meta_index_object_spec.rb +1 -1
  53. data/spec/models/order_list_response_spec.rb +1 -1
  54. data/spec/models/order_response_spec.rb +1 -1
  55. data/spec/models/order_spec.rb +1 -1
  56. data/spec/models/preference_list_response_spec.rb +1 -1
  57. data/spec/models/preference_response_spec.rb +1 -1
  58. data/spec/models/project_list_response_spec.rb +1 -1
  59. data/spec/models/project_response_spec.rb +1 -1
  60. data/spec/models/project_spec.rb +1 -1
  61. data/spec/spec_helper.rb +69 -61
  62. metadata +56 -58
  63. data/lib/patch_ruby/.api_client.rb.un~ +0 -0
  64. data/lib/patch_ruby/.configuration.rb.un~ +0 -0
  65. data/lib/patch_ruby/.version.rb.un~ +0 -0
  66. data/lib/patch_ruby/api/.orders_api.rb.un~ +0 -0
  67. data/lib/patch_ruby/models/.create_ethereum_estimate_request.rb.un~ +0 -0
  68. data/spec/.spec_helper.rb.un~ +0 -0
  69. data/spec/integration/.estimates_spec.rb.un~ +0 -0
  70. data/spec/integration/.orders_spec.rb.un~ +0 -0
  71. data/spec/integration/.preferences_spec.rb.un~ +0 -0
  72. data/spec/integration/.projects_spec.rb.un~ +0 -0
@@ -0,0 +1,247 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Patch
17
+ class CreateSuccessResponse
18
+ attr_accessor :success
19
+
20
+ attr_accessor :error
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :'success' => :'success',
26
+ :'error' => :'error'
27
+ }
28
+ end
29
+
30
+ # Returns all the JSON keys this model knows about
31
+ def self.acceptable_attributes
32
+ attribute_map.values
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'success' => :'Boolean',
39
+ :'error' => :'Object'
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new([
46
+ ])
47
+ end
48
+
49
+
50
+ # Allows models with corresponding API classes to delegate API operations to those API classes
51
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
52
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
53
+ def self.method_missing(message, *args, &block)
54
+ if Object.const_defined?('Patch::CreateSuccessResponsesApi::OPERATIONS') && Patch::CreateSuccessResponsesApi::OPERATIONS.include?(message)
55
+ Patch::CreateSuccessResponsesApi.new.send(message, *args)
56
+ else
57
+ super
58
+ end
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateSuccessResponse` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateSuccessResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'success')
77
+ self.success = attributes[:'success']
78
+ end
79
+
80
+ if attributes.key?(:'error')
81
+ self.error = attributes[:'error']
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ invalid_properties = Array.new
89
+ if @success.nil?
90
+ invalid_properties.push('invalid value for "success", success cannot be nil.')
91
+ end
92
+
93
+ if @error.nil?
94
+ invalid_properties.push('invalid value for "error", error cannot be nil.')
95
+ end
96
+
97
+ invalid_properties
98
+ end
99
+
100
+ # Check to see if the all the properties in the model are valid
101
+ # @return true if the model is valid
102
+ def valid?
103
+ return false if @success.nil?
104
+ return false if @error.nil?
105
+ true
106
+ end
107
+
108
+ # Checks equality by comparing each attribute.
109
+ # @param [Object] Object to be compared
110
+ def ==(o)
111
+ return true if self.equal?(o)
112
+ self.class == o.class &&
113
+ success == o.success &&
114
+ error == o.error
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(o)
120
+ self == o
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [success, error].hash
127
+ end
128
+
129
+ # Builds the object from hash
130
+ # @param [Hash] attributes Model attributes in the form of hash
131
+ # @return [Object] Returns the model itself
132
+ def self.build_from_hash(attributes)
133
+ new.build_from_hash(attributes)
134
+ end
135
+
136
+ # Builds the object from hash
137
+ # @param [Hash] attributes Model attributes in the form of hash
138
+ # @return [Object] Returns the model itself
139
+ def build_from_hash(attributes)
140
+ return nil unless attributes.is_a?(Hash)
141
+ self.class.openapi_types.each_pair do |key, type|
142
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
143
+ self.send("#{key}=", nil)
144
+ elsif type =~ /\AArray<(.*)>/i
145
+ # check to ensure the input is an array given that the attribute
146
+ # is documented as an array but the input is not
147
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
148
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
149
+ end
150
+ elsif !attributes[self.class.attribute_map[key]].nil?
151
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
152
+ end
153
+ end
154
+
155
+ self
156
+ end
157
+
158
+ # Deserializes the data based on type
159
+ # @param string type Data type
160
+ # @param string value Value to be deserialized
161
+ # @return [Object] Deserialized data
162
+ def _deserialize(type, value)
163
+ case type.to_sym
164
+ when :Time
165
+ Time.parse(value)
166
+ when :Date
167
+ Date.parse(value)
168
+ when :String
169
+ value.to_s
170
+ when :Integer
171
+ value.to_i
172
+ when :Float
173
+ value.to_f
174
+ when :Boolean
175
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
176
+ true
177
+ else
178
+ false
179
+ end
180
+ when :Object
181
+ # generic object (usually a Hash), return directly
182
+ value
183
+ when /\AArray<(?<inner_type>.+)>\z/
184
+ inner_type = Regexp.last_match[:inner_type]
185
+ value.map { |v| _deserialize(inner_type, v) }
186
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
187
+ k_type = Regexp.last_match[:k_type]
188
+ v_type = Regexp.last_match[:v_type]
189
+ {}.tap do |hash|
190
+ value.each do |k, v|
191
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
192
+ end
193
+ end
194
+ else # model
195
+ # models (e.g. Pet) or oneOf
196
+ klass = Patch.const_get(type)
197
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
198
+ end
199
+ end
200
+
201
+ # Returns the string representation of the object
202
+ # @return [String] String presentation of the object
203
+ def to_s
204
+ to_hash.to_s
205
+ end
206
+
207
+ # to_body is an alias to to_hash (backward compatibility)
208
+ # @return [Hash] Returns the object in the form of hash
209
+ def to_body
210
+ to_hash
211
+ end
212
+
213
+ # Returns the object in the form of hash
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_hash
216
+ hash = {}
217
+ self.class.attribute_map.each_pair do |attr, param|
218
+ value = self.send(attr)
219
+ if value.nil?
220
+ is_nullable = self.class.openapi_nullable.include?(attr)
221
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
222
+ end
223
+
224
+ hash[param] = _to_hash(value)
225
+ end
226
+ hash
227
+ end
228
+
229
+ # Outputs non-array value in the form of hash
230
+ # For object, use to_hash. Otherwise, just return the value
231
+ # @param [Object] value Any valid value
232
+ # @return [Hash] Returns the value in the form of hash
233
+ def _to_hash(value)
234
+ if value.is_a?(Array)
235
+ value.compact.map { |v| _to_hash(v) }
236
+ elsif value.is_a?(Hash)
237
+ {}.tap do |hash|
238
+ value.each { |k, v| hash[k] = _to_hash(v) }
239
+ end
240
+ elsif value.respond_to? :to_hash
241
+ value.to_hash
242
+ else
243
+ value
244
+ end
245
+ end
246
+ end
247
+ end
@@ -0,0 +1,326 @@
1
+ =begin
2
+ #Patch API V1
3
+
4
+ #The core API used to integrate with Patch's service
5
+
6
+ The version of the OpenAPI document: v1
7
+ Contact: developers@usepatch.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module Patch
17
+ class CreateVehicleEstimateRequest
18
+ attr_accessor :distance_m
19
+
20
+ attr_accessor :make
21
+
22
+ attr_accessor :model
23
+
24
+ attr_accessor :year
25
+
26
+ attr_accessor :project_id
27
+
28
+ attr_accessor :create_order
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'distance_m' => :'distance_m',
34
+ :'make' => :'make',
35
+ :'model' => :'model',
36
+ :'year' => :'year',
37
+ :'project_id' => :'project_id',
38
+ :'create_order' => :'create_order'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'distance_m' => :'Integer',
51
+ :'make' => :'String',
52
+ :'model' => :'String',
53
+ :'year' => :'Integer',
54
+ :'project_id' => :'String',
55
+ :'create_order' => :'Boolean'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ :'make',
63
+ :'model',
64
+ :'year',
65
+ :'project_id',
66
+ :'create_order'
67
+ ])
68
+ end
69
+
70
+
71
+ # Allows models with corresponding API classes to delegate API operations to those API classes
72
+ # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
73
+ # Eg. Order.create_order delegates to OrdersApi.new.create_order
74
+ def self.method_missing(message, *args, &block)
75
+ if Object.const_defined?('Patch::CreateVehicleEstimateRequestsApi::OPERATIONS') && Patch::CreateVehicleEstimateRequestsApi::OPERATIONS.include?(message)
76
+ Patch::CreateVehicleEstimateRequestsApi.new.send(message, *args)
77
+ else
78
+ super
79
+ end
80
+ end
81
+
82
+ # Initializes the object
83
+ # @param [Hash] attributes Model attributes in the form of hash
84
+ def initialize(attributes = {})
85
+ if (!attributes.is_a?(Hash))
86
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateVehicleEstimateRequest` initialize method"
87
+ end
88
+
89
+ # check to see if the attribute exists and convert string to symbol for hash key
90
+ attributes = attributes.each_with_object({}) { |(k, v), h|
91
+ if (!self.class.attribute_map.key?(k.to_sym))
92
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateVehicleEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
93
+ end
94
+ h[k.to_sym] = v
95
+ }
96
+
97
+ if attributes.key?(:'distance_m')
98
+ self.distance_m = attributes[:'distance_m']
99
+ end
100
+
101
+ if attributes.key?(:'make')
102
+ self.make = attributes[:'make']
103
+ end
104
+
105
+ if attributes.key?(:'model')
106
+ self.model = attributes[:'model']
107
+ end
108
+
109
+ if attributes.key?(:'year')
110
+ self.year = attributes[:'year']
111
+ end
112
+
113
+ if attributes.key?(:'project_id')
114
+ self.project_id = attributes[:'project_id']
115
+ end
116
+
117
+ if attributes.key?(:'create_order')
118
+ self.create_order = attributes[:'create_order']
119
+ end
120
+ end
121
+
122
+ # Show invalid properties with the reasons. Usually used together with valid?
123
+ # @return Array for valid properties with the reasons
124
+ def list_invalid_properties
125
+ invalid_properties = Array.new
126
+ if @distance_m.nil?
127
+ invalid_properties.push('invalid value for "distance_m", distance_m cannot be nil.')
128
+ end
129
+
130
+ if @distance_m > 400000000
131
+ invalid_properties.push('invalid value for "distance_m", must be smaller than or equal to 400000000.')
132
+ end
133
+
134
+ if @distance_m < 0
135
+ invalid_properties.push('invalid value for "distance_m", must be greater than or equal to 0.')
136
+ end
137
+
138
+ if !@year.nil? && @year < 1900
139
+ invalid_properties.push('invalid value for "year", must be greater than or equal to 1900.')
140
+ end
141
+
142
+ invalid_properties
143
+ end
144
+
145
+ # Check to see if the all the properties in the model are valid
146
+ # @return true if the model is valid
147
+ def valid?
148
+ return false if @distance_m.nil?
149
+ return false if @distance_m > 400000000
150
+ return false if @distance_m < 0
151
+ return false if !@year.nil? && @year < 1900
152
+ true
153
+ end
154
+
155
+ # Custom attribute writer method with validation
156
+ # @param [Object] distance_m Value to be assigned
157
+ def distance_m=(distance_m)
158
+ if distance_m.nil?
159
+ fail ArgumentError, 'distance_m cannot be nil'
160
+ end
161
+
162
+ if distance_m > 400000000
163
+ fail ArgumentError, 'invalid value for "distance_m", must be smaller than or equal to 400000000.'
164
+ end
165
+
166
+ if distance_m < 0
167
+ fail ArgumentError, 'invalid value for "distance_m", must be greater than or equal to 0.'
168
+ end
169
+
170
+ @distance_m = distance_m
171
+ end
172
+
173
+ # Custom attribute writer method with validation
174
+ # @param [Object] year Value to be assigned
175
+ def year=(year)
176
+ if !year.nil? && year < 1900
177
+ fail ArgumentError, 'invalid value for "year", must be greater than or equal to 1900.'
178
+ end
179
+
180
+ @year = year
181
+ end
182
+
183
+ # Checks equality by comparing each attribute.
184
+ # @param [Object] Object to be compared
185
+ def ==(o)
186
+ return true if self.equal?(o)
187
+ self.class == o.class &&
188
+ distance_m == o.distance_m &&
189
+ make == o.make &&
190
+ model == o.model &&
191
+ year == o.year &&
192
+ project_id == o.project_id &&
193
+ create_order == o.create_order
194
+ end
195
+
196
+ # @see the `==` method
197
+ # @param [Object] Object to be compared
198
+ def eql?(o)
199
+ self == o
200
+ end
201
+
202
+ # Calculates hash code according to all attributes.
203
+ # @return [Integer] Hash code
204
+ def hash
205
+ [distance_m, make, model, year, project_id, create_order].hash
206
+ end
207
+
208
+ # Builds the object from hash
209
+ # @param [Hash] attributes Model attributes in the form of hash
210
+ # @return [Object] Returns the model itself
211
+ def self.build_from_hash(attributes)
212
+ new.build_from_hash(attributes)
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ self.class.openapi_types.each_pair do |key, type|
221
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
222
+ self.send("#{key}=", nil)
223
+ elsif type =~ /\AArray<(.*)>/i
224
+ # check to ensure the input is an array given that the attribute
225
+ # is documented as an array but the input is not
226
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
227
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
228
+ end
229
+ elsif !attributes[self.class.attribute_map[key]].nil?
230
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
231
+ end
232
+ end
233
+
234
+ self
235
+ end
236
+
237
+ # Deserializes the data based on type
238
+ # @param string type Data type
239
+ # @param string value Value to be deserialized
240
+ # @return [Object] Deserialized data
241
+ def _deserialize(type, value)
242
+ case type.to_sym
243
+ when :Time
244
+ Time.parse(value)
245
+ when :Date
246
+ Date.parse(value)
247
+ when :String
248
+ value.to_s
249
+ when :Integer
250
+ value.to_i
251
+ when :Float
252
+ value.to_f
253
+ when :Boolean
254
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
255
+ true
256
+ else
257
+ false
258
+ end
259
+ when :Object
260
+ # generic object (usually a Hash), return directly
261
+ value
262
+ when /\AArray<(?<inner_type>.+)>\z/
263
+ inner_type = Regexp.last_match[:inner_type]
264
+ value.map { |v| _deserialize(inner_type, v) }
265
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
266
+ k_type = Regexp.last_match[:k_type]
267
+ v_type = Regexp.last_match[:v_type]
268
+ {}.tap do |hash|
269
+ value.each do |k, v|
270
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
271
+ end
272
+ end
273
+ else # model
274
+ # models (e.g. Pet) or oneOf
275
+ klass = Patch.const_get(type)
276
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
277
+ end
278
+ end
279
+
280
+ # Returns the string representation of the object
281
+ # @return [String] String presentation of the object
282
+ def to_s
283
+ to_hash.to_s
284
+ end
285
+
286
+ # to_body is an alias to to_hash (backward compatibility)
287
+ # @return [Hash] Returns the object in the form of hash
288
+ def to_body
289
+ to_hash
290
+ end
291
+
292
+ # Returns the object in the form of hash
293
+ # @return [Hash] Returns the object in the form of hash
294
+ def to_hash
295
+ hash = {}
296
+ self.class.attribute_map.each_pair do |attr, param|
297
+ value = self.send(attr)
298
+ if value.nil?
299
+ is_nullable = self.class.openapi_nullable.include?(attr)
300
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
301
+ end
302
+
303
+ hash[param] = _to_hash(value)
304
+ end
305
+ hash
306
+ end
307
+
308
+ # Outputs non-array value in the form of hash
309
+ # For object, use to_hash. Otherwise, just return the value
310
+ # @param [Object] value Any valid value
311
+ # @return [Hash] Returns the value in the form of hash
312
+ def _to_hash(value)
313
+ if value.is_a?(Array)
314
+ value.compact.map { |v| _to_hash(v) }
315
+ elsif value.is_a?(Hash)
316
+ {}.tap do |hash|
317
+ value.each { |k, v| hash[k] = _to_hash(v) }
318
+ end
319
+ elsif value.respond_to? :to_hash
320
+ value.to_hash
321
+ else
322
+ value
323
+ end
324
+ end
325
+ end
326
+ end