algolia 3.24.0 → 3.26.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 (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +18 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +63 -6
  8. data/lib/algolia/api/search_client.rb +10 -5
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_injected_item.rb +212 -0
  31. data/lib/algolia/models/composition/external_injection.rb +223 -0
  32. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  33. data/lib/algolia/models/composition/external_source.rb +211 -0
  34. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  35. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  36. data/lib/algolia/models/composition/injected_item.rb +253 -0
  37. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  38. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  39. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  40. data/lib/algolia/models/composition/injection.rb +222 -0
  41. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  42. data/lib/algolia/models/composition/main.rb +207 -0
  43. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  44. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  45. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  46. data/lib/algolia/models/composition/optional_words.rb +110 -0
  47. data/lib/algolia/models/composition/params.rb +17 -4
  48. data/lib/algolia/models/composition/query_type.rb +35 -0
  49. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  50. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  51. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  52. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  53. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  54. data/lib/algolia/models/composition/search.rb +217 -0
  55. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  56. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  57. data/lib/algolia/models/composition/search_source.rb +211 -0
  58. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  59. data/lib/algolia/models/composition/task_status.rb +34 -0
  60. data/lib/algolia/models/composition/time_range.rb +219 -0
  61. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  62. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  63. data/lib/algolia/models/ingestion/task_replace.rb +310 -0
  64. data/lib/algolia/models/ingestion/task_update.rb +1 -1
  65. data/lib/algolia/models/search/consequence.rb +1 -1
  66. data/lib/algolia/transport/transport.rb +6 -1
  67. data/lib/algolia/version.rb +1 -1
  68. metadata +55 -1
@@ -0,0 +1,111 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Composition
10
+ # Treat singular, plurals, and other forms of declensions as equivalent. You should only use this feature for the languages used in your index.
11
+ module IgnorePlurals
12
+ class << self
13
+ # List of class defined in oneOf (OpenAPI v3)
14
+ def openapi_one_of
15
+ [
16
+ :"Array<SupportedLanguage>",
17
+ :"Boolean",
18
+ :"BooleanString"
19
+ ]
20
+ end
21
+
22
+ # Builds the object
23
+ # @param [Mixed] Data to be matched against the list of oneOf items
24
+ # @return [Object] Returns the model or the data itself
25
+ def build(data)
26
+ # Go through the list of oneOf items and attempt to identify the appropriate one.
27
+ # Note:
28
+ # - We do not attempt to check whether exactly one item matches.
29
+ # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
30
+ # due to the way the deserialization is made in the base_object template (it just casts without verifying).
31
+ # - TODO: scalar values are de facto behaving as if they were nullable.
32
+ # - TODO: logging when debugging is set.
33
+ openapi_one_of.each do |klass|
34
+ begin
35
+ # "nullable: true"
36
+ next if klass == :AnyType
37
+ typed_data = find_and_cast_into_type(klass, data)
38
+ return typed_data if typed_data
39
+ # rescue all errors so we keep iterating even if the current item lookup raises
40
+ rescue
41
+ end
42
+ end
43
+
44
+ openapi_one_of.include?(:AnyType) ? data : nil
45
+ end
46
+
47
+ private
48
+
49
+ SchemaMismatchError = Class.new(StandardError)
50
+
51
+ def find_and_cast_into_type(klass, data)
52
+ return if data.nil?
53
+
54
+ case klass.to_s
55
+ when "Boolean"
56
+ return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
57
+ when "Float"
58
+ return data if data.instance_of?(Float)
59
+ when "Integer"
60
+ return data if data.instance_of?(Integer)
61
+ when "Time"
62
+ return Time.parse(data)
63
+ when "Date"
64
+ return Date.parse(data)
65
+ when "String"
66
+ return data if data.instance_of?(String)
67
+ # "type: object"
68
+ when "Object"
69
+ return data if data.instance_of?(Hash)
70
+ # "type: array"
71
+ when /\AArray<(?<sub_type>.+)>\z/
72
+ if data.instance_of?(Array)
73
+ sub_type = Regexp.last_match[:sub_type]
74
+ return data.map { |item| find_and_cast_into_type(sub_type, item) }
75
+ end
76
+ # "type: object" with "additionalProperties: { ... }"
77
+ when /\AHash<String, (?<sub_type>.+)>\z/
78
+ if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
79
+ sub_type = Regexp.last_match[:sub_type]
80
+ return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
81
+ end
82
+ # model
83
+ else
84
+ const = Algolia::Composition.const_get(klass)
85
+ if const
86
+ if const.respond_to?(:openapi_one_of)
87
+ # nested oneOf model
88
+ model = const.build(data)
89
+ elsif const.respond_to?(:discriminator_attributes)
90
+ if const.discriminator_attributes.all? { |attr| data.key?(attr) }
91
+ model = const.build_from_hash(data)
92
+ end
93
+ else
94
+ # maybe it's an enum, or doens't have discriminators
95
+ model = const.build_from_hash(data)
96
+ end
97
+
98
+ return model if model
99
+ end
100
+ end
101
+
102
+ # if no match by now, raise
103
+ raise
104
+ rescue
105
+ raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
106
+ end
107
+ end
108
+ end
109
+
110
+ end
111
+ end
@@ -0,0 +1,253 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Composition
10
+ class InjectedItem
11
+ # injected Item unique identifier.
12
+ attr_accessor :key
13
+
14
+ attr_accessor :source
15
+
16
+ attr_accessor :position
17
+
18
+ attr_accessor :length
19
+
20
+ attr_accessor :metadata
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :key => :key,
26
+ :source => :source,
27
+ :position => :position,
28
+ :length => :length,
29
+ :metadata => :metadata
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :key => :"String",
37
+ :source => :"InjectedItemSource",
38
+ :position => :"Integer",
39
+ :length => :"Integer",
40
+ :metadata => :"InjectedItemMetadata"
41
+ }
42
+ end
43
+
44
+ # List of attributes with nullable: true
45
+ def self.openapi_nullable
46
+ Set.new(
47
+ []
48
+ )
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ raise(
56
+ ArgumentError,
57
+ "The input argument (attributes) must be a hash in `Algolia::InjectedItem` initialize method"
58
+ )
59
+ end
60
+
61
+ # check to see if the attribute exists and convert string to symbol for hash key
62
+ attributes = attributes.each_with_object({}) { |(k, v), h|
63
+ if (!self.class.attribute_map.key?(k.to_sym))
64
+ raise(
65
+ ArgumentError,
66
+ "`#{k}` is not a valid attribute in `Algolia::InjectedItem`. Please check the name to make sure it's valid. List of attributes: " +
67
+ self.class.attribute_map.keys.inspect
68
+ )
69
+ end
70
+
71
+ h[k.to_sym] = v
72
+ }
73
+
74
+ if attributes.key?(:key)
75
+ self.key = attributes[:key]
76
+ else
77
+ self.key = nil
78
+ end
79
+
80
+ if attributes.key?(:source)
81
+ self.source = attributes[:source]
82
+ else
83
+ self.source = nil
84
+ end
85
+
86
+ if attributes.key?(:position)
87
+ self.position = attributes[:position]
88
+ else
89
+ self.position = nil
90
+ end
91
+
92
+ if attributes.key?(:length)
93
+ self.length = attributes[:length]
94
+ else
95
+ self.length = nil
96
+ end
97
+
98
+ if attributes.key?(:metadata)
99
+ self.metadata = attributes[:metadata]
100
+ end
101
+ end
102
+
103
+ # Checks equality by comparing each attribute.
104
+ # @param [Object] Object to be compared
105
+ def ==(other)
106
+ return true if self.equal?(other)
107
+ self.class == other.class &&
108
+ key == other.key &&
109
+ source == other.source &&
110
+ position == other.position &&
111
+ length == other.length &&
112
+ metadata == other.metadata
113
+ end
114
+
115
+ # @see the `==` method
116
+ # @param [Object] Object to be compared
117
+ def eql?(other)
118
+ self == other
119
+ end
120
+
121
+ # Calculates hash code according to all attributes.
122
+ # @return [Integer] Hash code
123
+ def hash
124
+ [key, source, position, length, metadata].hash
125
+ end
126
+
127
+ # Builds the object from hash
128
+ # @param [Hash] attributes Model attributes in the form of hash
129
+ # @return [Object] Returns the model itself
130
+ def self.build_from_hash(attributes)
131
+ return nil unless attributes.is_a?(Hash)
132
+ attributes = attributes.transform_keys(&:to_sym)
133
+ transformed_hash = {}
134
+ types_mapping.each_pair do |key, type|
135
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
136
+ transformed_hash[key.to_sym] = nil
137
+ elsif type =~ /\AArray<(.*)>/i
138
+ # check to ensure the input is an array given that the attribute
139
+ # is documented as an array but the input is not
140
+ if attributes[attribute_map[key]].is_a?(Array)
141
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
142
+ _deserialize(::Regexp.last_match(1), v)
143
+ }
144
+ end
145
+ elsif !attributes[attribute_map[key]].nil?
146
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
147
+ end
148
+ end
149
+
150
+ new(transformed_hash)
151
+ end
152
+
153
+ # Deserializes the data based on type
154
+ # @param string type Data type
155
+ # @param string value Value to be deserialized
156
+ # @return [Object] Deserialized data
157
+ def self._deserialize(type, value)
158
+ case type.to_sym
159
+ when :Time
160
+ Time.parse(value)
161
+ when :Date
162
+ Date.parse(value)
163
+ when :String
164
+ value.to_s
165
+ when :Integer
166
+ value.to_i
167
+ when :Float
168
+ value.to_f
169
+ when :Boolean
170
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
171
+ true
172
+ else
173
+ false
174
+ end
175
+
176
+ when :Object
177
+ # generic object (usually a Hash), return directly
178
+ value
179
+ when /\AArray<(?<inner_type>.+)>\z/
180
+ inner_type = Regexp.last_match[:inner_type]
181
+ value.map { |v| _deserialize(inner_type, v) }
182
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
183
+ k_type = Regexp.last_match[:k_type]
184
+ v_type = Regexp.last_match[:v_type]
185
+ {}.tap do |hash|
186
+ value.each do |k, v|
187
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
188
+ end
189
+ end
190
+ # model
191
+ else
192
+ # models (e.g. Pet) or oneOf
193
+ klass = Algolia::Composition.const_get(type)
194
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
195
+ .build_from_hash(value)
196
+ end
197
+ end
198
+
199
+ # Returns the string representation of the object
200
+ # @return [String] String presentation of the object
201
+ def to_s
202
+ to_hash.to_s
203
+ end
204
+
205
+ # to_body is an alias to to_hash (backward compatibility)
206
+ # @return [Hash] Returns the object in the form of hash
207
+ def to_body
208
+ to_hash
209
+ end
210
+
211
+ def to_json(*_args)
212
+ to_hash.to_json
213
+ end
214
+
215
+ # Returns the object in the form of hash
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_hash
218
+ hash = {}
219
+ self.class.attribute_map.each_pair do |attr, param|
220
+ value = send(attr)
221
+ if value.nil?
222
+ is_nullable = self.class.openapi_nullable.include?(attr)
223
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
224
+ end
225
+
226
+ hash[param] = _to_hash(value)
227
+ end
228
+
229
+ hash
230
+ end
231
+
232
+ # Outputs non-array value in the form of hash
233
+ # For object, use to_hash. Otherwise, just return the value
234
+ # @param [Object] value Any valid value
235
+ # @return [Hash] Returns the value in the form of hash
236
+ def _to_hash(value)
237
+ if value.is_a?(Array)
238
+ value.compact.map { |v| _to_hash(v) }
239
+ elsif value.is_a?(Hash)
240
+ {}.tap do |hash|
241
+ value.each { |k, v| hash[k] = _to_hash(v) }
242
+ end
243
+ elsif value.respond_to?(:to_hash)
244
+ value.to_hash
245
+ else
246
+ value
247
+ end
248
+ end
249
+
250
+ end
251
+
252
+ end
253
+ end
@@ -0,0 +1,222 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
4
+
5
+ require "date"
6
+ require "time"
7
+
8
+ module Algolia
9
+ module Composition
10
+ # Adds the provided metadata to each injected hit via an `_extra` attribute.
11
+ class InjectedItemHitsMetadata
12
+ # When true, the `_injectedItemKey` field is set in the `_extra` object of each affected hit.
13
+ attr_accessor :add_item_key
14
+
15
+ # The user-defined key-value pairs that will be placed in the `_extra` field of each affected hit.
16
+ attr_accessor :extra
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :add_item_key => :addItemKey,
22
+ :extra => :extra
23
+ }
24
+ end
25
+
26
+ # Attribute type mapping.
27
+ def self.types_mapping
28
+ {
29
+ :add_item_key => :"Boolean",
30
+ :extra => :"Hash<String, Object>"
31
+ }
32
+ end
33
+
34
+ # List of attributes with nullable: true
35
+ def self.openapi_nullable
36
+ Set.new(
37
+ []
38
+ )
39
+ end
40
+
41
+ # Initializes the object
42
+ # @param [Hash] attributes Model attributes in the form of hash
43
+ def initialize(attributes = {})
44
+ if (!attributes.is_a?(Hash))
45
+ raise(
46
+ ArgumentError,
47
+ "The input argument (attributes) must be a hash in `Algolia::InjectedItemHitsMetadata` initialize method"
48
+ )
49
+ end
50
+
51
+ # check to see if the attribute exists and convert string to symbol for hash key
52
+ attributes = attributes.each_with_object({}) { |(k, v), h|
53
+ if (!self.class.attribute_map.key?(k.to_sym))
54
+ raise(
55
+ ArgumentError,
56
+ "`#{k}` is not a valid attribute in `Algolia::InjectedItemHitsMetadata`. Please check the name to make sure it's valid. List of attributes: " +
57
+ self.class.attribute_map.keys.inspect
58
+ )
59
+ end
60
+
61
+ h[k.to_sym] = v
62
+ }
63
+
64
+ if attributes.key?(:add_item_key)
65
+ self.add_item_key = attributes[:add_item_key]
66
+ end
67
+
68
+ if attributes.key?(:extra)
69
+ if (value = attributes[:extra]).is_a?(Hash)
70
+ self.extra = value
71
+ end
72
+ end
73
+ end
74
+
75
+ # Checks equality by comparing each attribute.
76
+ # @param [Object] Object to be compared
77
+ def ==(other)
78
+ return true if self.equal?(other)
79
+ self.class == other.class &&
80
+ add_item_key == other.add_item_key &&
81
+ extra == other.extra
82
+ end
83
+
84
+ # @see the `==` method
85
+ # @param [Object] Object to be compared
86
+ def eql?(other)
87
+ self == other
88
+ end
89
+
90
+ # Calculates hash code according to all attributes.
91
+ # @return [Integer] Hash code
92
+ def hash
93
+ [add_item_key, extra].hash
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def self.build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ attributes = attributes.transform_keys(&:to_sym)
102
+ transformed_hash = {}
103
+ types_mapping.each_pair do |key, type|
104
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
105
+ transformed_hash[key.to_sym] = nil
106
+ elsif type =~ /\AArray<(.*)>/i
107
+ # check to ensure the input is an array given that the attribute
108
+ # is documented as an array but the input is not
109
+ if attributes[attribute_map[key]].is_a?(Array)
110
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
111
+ _deserialize(::Regexp.last_match(1), v)
112
+ }
113
+ end
114
+ elsif !attributes[attribute_map[key]].nil?
115
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
116
+ end
117
+ end
118
+
119
+ new(transformed_hash)
120
+ end
121
+
122
+ # Deserializes the data based on type
123
+ # @param string type Data type
124
+ # @param string value Value to be deserialized
125
+ # @return [Object] Deserialized data
126
+ def self._deserialize(type, value)
127
+ case type.to_sym
128
+ when :Time
129
+ Time.parse(value)
130
+ when :Date
131
+ Date.parse(value)
132
+ when :String
133
+ value.to_s
134
+ when :Integer
135
+ value.to_i
136
+ when :Float
137
+ value.to_f
138
+ when :Boolean
139
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
140
+ true
141
+ else
142
+ false
143
+ end
144
+
145
+ when :Object
146
+ # generic object (usually a Hash), return directly
147
+ value
148
+ when /\AArray<(?<inner_type>.+)>\z/
149
+ inner_type = Regexp.last_match[:inner_type]
150
+ value.map { |v| _deserialize(inner_type, v) }
151
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
152
+ k_type = Regexp.last_match[:k_type]
153
+ v_type = Regexp.last_match[:v_type]
154
+ {}.tap do |hash|
155
+ value.each do |k, v|
156
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
157
+ end
158
+ end
159
+ # model
160
+ else
161
+ # models (e.g. Pet) or oneOf
162
+ klass = Algolia::Composition.const_get(type)
163
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
164
+ .build_from_hash(value)
165
+ end
166
+ end
167
+
168
+ # Returns the string representation of the object
169
+ # @return [String] String presentation of the object
170
+ def to_s
171
+ to_hash.to_s
172
+ end
173
+
174
+ # to_body is an alias to to_hash (backward compatibility)
175
+ # @return [Hash] Returns the object in the form of hash
176
+ def to_body
177
+ to_hash
178
+ end
179
+
180
+ def to_json(*_args)
181
+ to_hash.to_json
182
+ end
183
+
184
+ # Returns the object in the form of hash
185
+ # @return [Hash] Returns the object in the form of hash
186
+ def to_hash
187
+ hash = {}
188
+ self.class.attribute_map.each_pair do |attr, param|
189
+ value = send(attr)
190
+ if value.nil?
191
+ is_nullable = self.class.openapi_nullable.include?(attr)
192
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
193
+ end
194
+
195
+ hash[param] = _to_hash(value)
196
+ end
197
+
198
+ hash
199
+ end
200
+
201
+ # Outputs non-array value in the form of hash
202
+ # For object, use to_hash. Otherwise, just return the value
203
+ # @param [Object] value Any valid value
204
+ # @return [Hash] Returns the value in the form of hash
205
+ def _to_hash(value)
206
+ if value.is_a?(Array)
207
+ value.compact.map { |v| _to_hash(v) }
208
+ elsif value.is_a?(Hash)
209
+ {}.tap do |hash|
210
+ value.each { |k, v| hash[k] = _to_hash(v) }
211
+ end
212
+ elsif value.respond_to?(:to_hash)
213
+ value.to_hash
214
+ else
215
+ value
216
+ end
217
+ end
218
+
219
+ end
220
+
221
+ end
222
+ end