patch_ruby 2.5.0 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +18 -25
  5. data/README.md +0 -52
  6. data/lib/patch_ruby/api_client.rb +1 -1
  7. data/lib/patch_ruby/version.rb +1 -1
  8. data/lib/patch_ruby.rb +0 -10
  9. data/spec/api/orders_api_spec.rb +0 -1
  10. data/spec/integration/orders_spec.rb +0 -25
  11. data/spec/integration/projects_spec.rb +1 -1
  12. metadata +15 -45
  13. data/lib/patch_ruby/api/estimates_api.rb +0 -612
  14. data/lib/patch_ruby/models/create_air_shipping_estimate_request.rb +0 -374
  15. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +0 -271
  16. data/lib/patch_ruby/models/create_mass_estimate_request.rb +0 -282
  17. data/lib/patch_ruby/models/create_rail_shipping_estimate_request.rb +0 -404
  18. data/lib/patch_ruby/models/create_road_shipping_estimate_request.rb +0 -517
  19. data/lib/patch_ruby/models/create_sea_shipping_estimate_request.rb +0 -461
  20. data/lib/patch_ruby/models/estimate.rb +0 -288
  21. data/lib/patch_ruby/models/estimate_list_response.rb +0 -273
  22. data/lib/patch_ruby/models/estimate_response.rb +0 -257
  23. data/spec/api/estimates_api_spec.rb +0 -70
  24. data/spec/factories/create_mass_estimate_requests.rb +0 -6
  25. data/spec/factories/estimate_list_responses.rb +0 -8
  26. data/spec/factories/estimate_responses.rb +0 -7
  27. data/spec/factories/estimates.rb +0 -8
  28. data/spec/integration/estimates_spec.rb +0 -218
  29. data/spec/models/create_mass_estimate_request_spec.rb +0 -46
  30. data/spec/models/estimate_list_response_spec.rb +0 -64
  31. data/spec/models/estimate_response_spec.rb +0 -58
  32. data/spec/models/estimate_spec.rb +0 -65
@@ -1,374 +0,0 @@
1
- =begin
2
- #Patch API V2
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: 2
7
- Contact: engineering@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Patch
17
- class CreateAirShippingEstimateRequest
18
- attr_accessor :destination_airport
19
-
20
- attr_accessor :origin_airport
21
-
22
- attr_accessor :aircraft_code
23
-
24
- attr_accessor :aircraft_type
25
-
26
- attr_accessor :freight_mass_g
27
-
28
- attr_accessor :emissions_scope
29
-
30
- attr_accessor :project_id
31
-
32
- attr_accessor :create_order
33
-
34
- class EnumAttributeValidator
35
- attr_reader :datatype
36
- attr_reader :allowable_values
37
-
38
- def initialize(datatype, allowable_values)
39
- @allowable_values = allowable_values.map do |value|
40
- case datatype.to_s
41
- when /Integer/i
42
- value.to_i
43
- when /Float/i
44
- value.to_f
45
- else
46
- value
47
- end
48
- end
49
- end
50
-
51
- def valid?(value)
52
- !value || allowable_values.include?(value)
53
- end
54
- end
55
-
56
- # Attribute mapping from ruby-style variable name to JSON key.
57
- def self.attribute_map
58
- {
59
- :'destination_airport' => :'destination_airport',
60
- :'origin_airport' => :'origin_airport',
61
- :'aircraft_code' => :'aircraft_code',
62
- :'aircraft_type' => :'aircraft_type',
63
- :'freight_mass_g' => :'freight_mass_g',
64
- :'emissions_scope' => :'emissions_scope',
65
- :'project_id' => :'project_id',
66
- :'create_order' => :'create_order'
67
- }
68
- end
69
-
70
- # Returns all the JSON keys this model knows about
71
- def self.acceptable_attributes
72
- attribute_map.values
73
- end
74
-
75
- # Attribute type mapping.
76
- def self.openapi_types
77
- {
78
- :'destination_airport' => :'String',
79
- :'origin_airport' => :'String',
80
- :'aircraft_code' => :'String',
81
- :'aircraft_type' => :'String',
82
- :'freight_mass_g' => :'Integer',
83
- :'emissions_scope' => :'String',
84
- :'project_id' => :'String',
85
- :'create_order' => :'Boolean'
86
- }
87
- end
88
-
89
- # List of attributes with nullable: true
90
- def self.openapi_nullable
91
- Set.new([
92
- :'destination_airport',
93
- :'origin_airport',
94
- :'aircraft_code',
95
- :'aircraft_type',
96
- :'emissions_scope',
97
- :'project_id',
98
- :'create_order'
99
- ])
100
- end
101
-
102
-
103
- # Allows models with corresponding API classes to delegate API operations to those API classes
104
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
105
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
106
- def self.method_missing(message, *args, &block)
107
- if Object.const_defined?('Patch::CreateAirShippingEstimateRequestsApi::OPERATIONS') && Patch::CreateAirShippingEstimateRequestsApi::OPERATIONS.include?(message)
108
- Patch::CreateAirShippingEstimateRequestsApi.new.send(message, *args)
109
- else
110
- super
111
- end
112
- end
113
-
114
- # Initializes the object
115
- # @param [Hash] attributes Model attributes in the form of hash
116
- def initialize(attributes = {})
117
- if (!attributes.is_a?(Hash))
118
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateAirShippingEstimateRequest` initialize method"
119
- end
120
-
121
- # check to see if the attribute exists and convert string to symbol for hash key
122
- attributes = attributes.each_with_object({}) { |(k, v), h|
123
- if (!self.class.attribute_map.key?(k.to_sym))
124
- fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateAirShippingEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
125
- end
126
- h[k.to_sym] = v
127
- }
128
-
129
- if attributes.key?(:'destination_airport')
130
- self.destination_airport = attributes[:'destination_airport']
131
- end
132
-
133
- if attributes.key?(:'origin_airport')
134
- self.origin_airport = attributes[:'origin_airport']
135
- end
136
-
137
- if attributes.key?(:'aircraft_code')
138
- self.aircraft_code = attributes[:'aircraft_code']
139
- end
140
-
141
- if attributes.key?(:'aircraft_type')
142
- self.aircraft_type = attributes[:'aircraft_type']
143
- else
144
- self.aircraft_type = 'unknown'
145
- end
146
-
147
- if attributes.key?(:'freight_mass_g')
148
- self.freight_mass_g = attributes[:'freight_mass_g']
149
- end
150
-
151
- if attributes.key?(:'emissions_scope')
152
- self.emissions_scope = attributes[:'emissions_scope']
153
- else
154
- self.emissions_scope = 'ttw'
155
- end
156
-
157
- if attributes.key?(:'project_id')
158
- self.project_id = attributes[:'project_id']
159
- end
160
-
161
- if attributes.key?(:'create_order')
162
- self.create_order = attributes[:'create_order']
163
- else
164
- self.create_order = false
165
- end
166
- end
167
-
168
- # Show invalid properties with the reasons. Usually used together with valid?
169
- # @return Array for valid properties with the reasons
170
- def list_invalid_properties
171
- invalid_properties = Array.new
172
- if !@freight_mass_g.nil? && @freight_mass_g > 2000000000
173
- invalid_properties.push('invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.')
174
- end
175
-
176
- if !@freight_mass_g.nil? && @freight_mass_g < 0
177
- invalid_properties.push('invalid value for "freight_mass_g", must be greater than or equal to 0.')
178
- end
179
-
180
- invalid_properties
181
- end
182
-
183
- # Check to see if the all the properties in the model are valid
184
- # @return true if the model is valid
185
- def valid?
186
- aircraft_type_validator = EnumAttributeValidator.new('String', ["passenger", "cargo", "unknown"])
187
- return false unless aircraft_type_validator.valid?(@aircraft_type)
188
- return false if !@freight_mass_g.nil? && @freight_mass_g > 2000000000
189
- return false if !@freight_mass_g.nil? && @freight_mass_g < 0
190
- emissions_scope_validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"])
191
- return false unless emissions_scope_validator.valid?(@emissions_scope)
192
- true
193
- end
194
-
195
- # Custom attribute writer method checking allowed values (enum).
196
- # @param [Object] aircraft_type Object to be assigned
197
- def aircraft_type=(aircraft_type)
198
- validator = EnumAttributeValidator.new('String', ["passenger", "cargo", "unknown"])
199
- unless validator.valid?(aircraft_type)
200
- fail ArgumentError, "invalid value for \"aircraft_type\", must be one of #{validator.allowable_values}."
201
- end
202
- @aircraft_type = aircraft_type
203
- end
204
-
205
- # Custom attribute writer method with validation
206
- # @param [Object] freight_mass_g Value to be assigned
207
- def freight_mass_g=(freight_mass_g)
208
- if !freight_mass_g.nil? && freight_mass_g > 2000000000
209
- fail ArgumentError, 'invalid value for "freight_mass_g", must be smaller than or equal to 2000000000.'
210
- end
211
-
212
- if !freight_mass_g.nil? && freight_mass_g < 0
213
- fail ArgumentError, 'invalid value for "freight_mass_g", must be greater than or equal to 0.'
214
- end
215
-
216
- @freight_mass_g = freight_mass_g
217
- end
218
-
219
- # Custom attribute writer method checking allowed values (enum).
220
- # @param [Object] emissions_scope Object to be assigned
221
- def emissions_scope=(emissions_scope)
222
- validator = EnumAttributeValidator.new('String', ["wtt", "ttw", "wtw"])
223
- unless validator.valid?(emissions_scope)
224
- fail ArgumentError, "invalid value for \"emissions_scope\", must be one of #{validator.allowable_values}."
225
- end
226
- @emissions_scope = emissions_scope
227
- end
228
-
229
- # Checks equality by comparing each attribute.
230
- # @param [Object] Object to be compared
231
- def ==(o)
232
- return true if self.equal?(o)
233
- self.class == o.class &&
234
- destination_airport == o.destination_airport &&
235
- origin_airport == o.origin_airport &&
236
- aircraft_code == o.aircraft_code &&
237
- aircraft_type == o.aircraft_type &&
238
- freight_mass_g == o.freight_mass_g &&
239
- emissions_scope == o.emissions_scope &&
240
- project_id == o.project_id &&
241
- create_order == o.create_order
242
- end
243
-
244
- # @see the `==` method
245
- # @param [Object] Object to be compared
246
- def eql?(o)
247
- self == o
248
- end
249
-
250
- # Calculates hash code according to all attributes.
251
- # @return [Integer] Hash code
252
- def hash
253
- [destination_airport, origin_airport, aircraft_code, aircraft_type, freight_mass_g, emissions_scope, project_id, create_order].hash
254
- end
255
-
256
- # Builds the object from hash
257
- # @param [Hash] attributes Model attributes in the form of hash
258
- # @return [Object] Returns the model itself
259
- def self.build_from_hash(attributes)
260
- new.build_from_hash(attributes)
261
- end
262
-
263
- # Builds the object from hash
264
- # @param [Hash] attributes Model attributes in the form of hash
265
- # @return [Object] Returns the model itself
266
- def build_from_hash(attributes)
267
- return nil unless attributes.is_a?(Hash)
268
- self.class.openapi_types.each_pair do |key, type|
269
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
270
- self.send("#{key}=", nil)
271
- elsif type =~ /\AArray<(.*)>/i
272
- # check to ensure the input is an array given that the attribute
273
- # is documented as an array but the input is not
274
- if attributes[self.class.attribute_map[key]].is_a?(Array)
275
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
276
- end
277
- elsif !attributes[self.class.attribute_map[key]].nil?
278
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
279
- end
280
- end
281
-
282
- self
283
- end
284
-
285
- # Deserializes the data based on type
286
- # @param string type Data type
287
- # @param string value Value to be deserialized
288
- # @return [Object] Deserialized data
289
- def _deserialize(type, value)
290
- case type.to_sym
291
- when :Time
292
- Time.parse(value)
293
- when :Date
294
- Date.parse(value)
295
- when :String
296
- value.to_s
297
- when :Integer
298
- value.to_i
299
- when :Float
300
- value.to_f
301
- when :Boolean
302
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
303
- true
304
- else
305
- false
306
- end
307
- when :Object
308
- # generic object (usually a Hash), return directly
309
- value
310
- when /\AArray<(?<inner_type>.+)>\z/
311
- inner_type = Regexp.last_match[:inner_type]
312
- value.map { |v| _deserialize(inner_type, v) }
313
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
314
- k_type = Regexp.last_match[:k_type]
315
- v_type = Regexp.last_match[:v_type]
316
- {}.tap do |hash|
317
- value.each do |k, v|
318
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
319
- end
320
- end
321
- else # model
322
- # models (e.g. Pet) or oneOf
323
- klass = Patch.const_get(type)
324
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
325
- end
326
- end
327
-
328
- # Returns the string representation of the object
329
- # @return [String] String presentation of the object
330
- def to_s
331
- to_hash.to_s
332
- end
333
-
334
- # to_body is an alias to to_hash (backward compatibility)
335
- # @return [Hash] Returns the object in the form of hash
336
- def to_body
337
- to_hash
338
- end
339
-
340
- # Returns the object in the form of hash
341
- # @return [Hash] Returns the object in the form of hash
342
- def to_hash
343
- hash = {}
344
- self.class.attribute_map.each_pair do |attr, param|
345
- value = self.send(attr)
346
- if value.nil?
347
- is_nullable = self.class.openapi_nullable.include?(attr)
348
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
349
- end
350
-
351
- hash[param] = _to_hash(value)
352
- end
353
- hash
354
- end
355
-
356
- # Outputs non-array value in the form of hash
357
- # For object, use to_hash. Otherwise, just return the value
358
- # @param [Object] value Any valid value
359
- # @return [Hash] Returns the value in the form of hash
360
- def _to_hash(value)
361
- if value.is_a?(Array)
362
- value.compact.map { |v| _to_hash(v) }
363
- elsif value.is_a?(Hash)
364
- {}.tap do |hash|
365
- value.each { |k, v| hash[k] = _to_hash(v) }
366
- end
367
- elsif value.respond_to? :to_hash
368
- value.to_hash
369
- else
370
- value
371
- end
372
- end
373
- end
374
- end
@@ -1,271 +0,0 @@
1
- =begin
2
- #Patch API V2
3
-
4
- #The core API used to integrate with Patch's service
5
-
6
- The version of the OpenAPI document: 2
7
- Contact: engineering@usepatch.com
8
- Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 5.3.1
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module Patch
17
- class CreateBitcoinEstimateRequest
18
- attr_accessor :timestamp
19
-
20
- attr_accessor :transaction_value_btc_sats
21
-
22
- attr_accessor :average_daily_balance_btc_sats
23
-
24
- attr_accessor :project_id
25
-
26
- attr_accessor :create_order
27
-
28
- # Attribute mapping from ruby-style variable name to JSON key.
29
- def self.attribute_map
30
- {
31
- :'timestamp' => :'timestamp',
32
- :'transaction_value_btc_sats' => :'transaction_value_btc_sats',
33
- :'average_daily_balance_btc_sats' => :'average_daily_balance_btc_sats',
34
- :'project_id' => :'project_id',
35
- :'create_order' => :'create_order'
36
- }
37
- end
38
-
39
- # Returns all the JSON keys this model knows about
40
- def self.acceptable_attributes
41
- attribute_map.values
42
- end
43
-
44
- # Attribute type mapping.
45
- def self.openapi_types
46
- {
47
- :'timestamp' => :'Time',
48
- :'transaction_value_btc_sats' => :'Integer',
49
- :'average_daily_balance_btc_sats' => :'Integer',
50
- :'project_id' => :'String',
51
- :'create_order' => :'Boolean'
52
- }
53
- end
54
-
55
- # List of attributes with nullable: true
56
- def self.openapi_nullable
57
- Set.new([
58
- :'timestamp',
59
- :'transaction_value_btc_sats',
60
- :'average_daily_balance_btc_sats',
61
- :'project_id',
62
- :'create_order'
63
- ])
64
- end
65
-
66
-
67
- # Allows models with corresponding API classes to delegate API operations to those API classes
68
- # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
69
- # Eg. Order.create_order delegates to OrdersApi.new.create_order
70
- def self.method_missing(message, *args, &block)
71
- if Object.const_defined?('Patch::CreateBitcoinEstimateRequestsApi::OPERATIONS') && Patch::CreateBitcoinEstimateRequestsApi::OPERATIONS.include?(message)
72
- Patch::CreateBitcoinEstimateRequestsApi.new.send(message, *args)
73
- else
74
- super
75
- end
76
- end
77
-
78
- # Initializes the object
79
- # @param [Hash] attributes Model attributes in the form of hash
80
- def initialize(attributes = {})
81
- if (!attributes.is_a?(Hash))
82
- fail ArgumentError, "The input argument (attributes) must be a hash in `Patch::CreateBitcoinEstimateRequest` initialize method"
83
- end
84
-
85
- # check to see if the attribute exists and convert string to symbol for hash key
86
- attributes = attributes.each_with_object({}) { |(k, v), h|
87
- if (!self.class.attribute_map.key?(k.to_sym))
88
- fail ArgumentError, "`#{k}` is not a valid attribute in `Patch::CreateBitcoinEstimateRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
89
- end
90
- h[k.to_sym] = v
91
- }
92
-
93
- if attributes.key?(:'timestamp')
94
- self.timestamp = attributes[:'timestamp']
95
- end
96
-
97
- if attributes.key?(:'transaction_value_btc_sats')
98
- self.transaction_value_btc_sats = attributes[:'transaction_value_btc_sats']
99
- end
100
-
101
- if attributes.key?(:'average_daily_balance_btc_sats')
102
- self.average_daily_balance_btc_sats = attributes[:'average_daily_balance_btc_sats']
103
- end
104
-
105
- if attributes.key?(:'project_id')
106
- self.project_id = attributes[:'project_id']
107
- end
108
-
109
- if attributes.key?(:'create_order')
110
- self.create_order = attributes[:'create_order']
111
- else
112
- self.create_order = false
113
- end
114
- end
115
-
116
- # Show invalid properties with the reasons. Usually used together with valid?
117
- # @return Array for valid properties with the reasons
118
- def list_invalid_properties
119
- invalid_properties = Array.new
120
- invalid_properties
121
- end
122
-
123
- # Check to see if the all the properties in the model are valid
124
- # @return true if the model is valid
125
- def valid?
126
- true
127
- end
128
-
129
- # Checks equality by comparing each attribute.
130
- # @param [Object] Object to be compared
131
- def ==(o)
132
- return true if self.equal?(o)
133
- self.class == o.class &&
134
- timestamp == o.timestamp &&
135
- transaction_value_btc_sats == o.transaction_value_btc_sats &&
136
- average_daily_balance_btc_sats == o.average_daily_balance_btc_sats &&
137
- project_id == o.project_id &&
138
- create_order == o.create_order
139
- end
140
-
141
- # @see the `==` method
142
- # @param [Object] Object to be compared
143
- def eql?(o)
144
- self == o
145
- end
146
-
147
- # Calculates hash code according to all attributes.
148
- # @return [Integer] Hash code
149
- def hash
150
- [timestamp, transaction_value_btc_sats, average_daily_balance_btc_sats, project_id, create_order].hash
151
- end
152
-
153
- # Builds the object from hash
154
- # @param [Hash] attributes Model attributes in the form of hash
155
- # @return [Object] Returns the model itself
156
- def self.build_from_hash(attributes)
157
- new.build_from_hash(attributes)
158
- end
159
-
160
- # Builds the object from hash
161
- # @param [Hash] attributes Model attributes in the form of hash
162
- # @return [Object] Returns the model itself
163
- def build_from_hash(attributes)
164
- return nil unless attributes.is_a?(Hash)
165
- self.class.openapi_types.each_pair do |key, type|
166
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
167
- self.send("#{key}=", nil)
168
- elsif type =~ /\AArray<(.*)>/i
169
- # check to ensure the input is an array given that the attribute
170
- # is documented as an array but the input is not
171
- if attributes[self.class.attribute_map[key]].is_a?(Array)
172
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
173
- end
174
- elsif !attributes[self.class.attribute_map[key]].nil?
175
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
- end
177
- end
178
-
179
- self
180
- end
181
-
182
- # Deserializes the data based on type
183
- # @param string type Data type
184
- # @param string value Value to be deserialized
185
- # @return [Object] Deserialized data
186
- def _deserialize(type, value)
187
- case type.to_sym
188
- when :Time
189
- Time.parse(value)
190
- when :Date
191
- Date.parse(value)
192
- when :String
193
- value.to_s
194
- when :Integer
195
- value.to_i
196
- when :Float
197
- value.to_f
198
- when :Boolean
199
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
- true
201
- else
202
- false
203
- end
204
- when :Object
205
- # generic object (usually a Hash), return directly
206
- value
207
- when /\AArray<(?<inner_type>.+)>\z/
208
- inner_type = Regexp.last_match[:inner_type]
209
- value.map { |v| _deserialize(inner_type, v) }
210
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
- k_type = Regexp.last_match[:k_type]
212
- v_type = Regexp.last_match[:v_type]
213
- {}.tap do |hash|
214
- value.each do |k, v|
215
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
- end
217
- end
218
- else # model
219
- # models (e.g. Pet) or oneOf
220
- klass = Patch.const_get(type)
221
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
- end
223
- end
224
-
225
- # Returns the string representation of the object
226
- # @return [String] String presentation of the object
227
- def to_s
228
- to_hash.to_s
229
- end
230
-
231
- # to_body is an alias to to_hash (backward compatibility)
232
- # @return [Hash] Returns the object in the form of hash
233
- def to_body
234
- to_hash
235
- end
236
-
237
- # Returns the object in the form of hash
238
- # @return [Hash] Returns the object in the form of hash
239
- def to_hash
240
- hash = {}
241
- self.class.attribute_map.each_pair do |attr, param|
242
- value = self.send(attr)
243
- if value.nil?
244
- is_nullable = self.class.openapi_nullable.include?(attr)
245
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
- end
247
-
248
- hash[param] = _to_hash(value)
249
- end
250
- hash
251
- end
252
-
253
- # Outputs non-array value in the form of hash
254
- # For object, use to_hash. Otherwise, just return the value
255
- # @param [Object] value Any valid value
256
- # @return [Hash] Returns the value in the form of hash
257
- def _to_hash(value)
258
- if value.is_a?(Array)
259
- value.compact.map { |v| _to_hash(v) }
260
- elsif value.is_a?(Hash)
261
- {}.tap do |hash|
262
- value.each { |k, v| hash[k] = _to_hash(v) }
263
- end
264
- elsif value.respond_to? :to_hash
265
- value.to_hash
266
- else
267
- value
268
- end
269
- end
270
- end
271
- end