algolia 3.42.2 → 3.43.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 (41) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/do-not-edit-this-repository.yml +1 -1
  3. data/.github/workflows/issue.yml +1 -1
  4. data/.github/workflows/release.yml +4 -4
  5. data/CHANGELOG.md +14 -0
  6. data/Gemfile.lock +2 -2
  7. data/lib/algolia/api/analytics_client.rb +221 -0
  8. data/lib/algolia/api/search_client.rb +16 -0
  9. data/lib/algolia/api_client.rb +4 -0
  10. data/lib/algolia/models/abtesting-v3/ab_test.rb +14 -4
  11. data/lib/algolia/models/abtesting-v3/decision.rb +219 -0
  12. data/lib/algolia/models/analytics/bin_edge.rb +109 -0
  13. data/lib/algolia/models/analytics/catalog.rb +208 -0
  14. data/lib/algolia/models/analytics/catalog_entry.rb +249 -0
  15. data/lib/algolia/models/analytics/distribution_definition.rb +243 -0
  16. data/lib/algolia/models/analytics/distribution_payload.rb +247 -0
  17. data/lib/algolia/models/analytics/domain_catalog.rb +253 -0
  18. data/lib/algolia/models/analytics/field_reference.rb +219 -0
  19. data/lib/algolia/models/analytics/filter_definition.rb +238 -0
  20. data/lib/algolia/models/analytics/order_definition.rb +230 -0
  21. data/lib/algolia/models/analytics/order_direction.rb +34 -0
  22. data/lib/algolia/models/analytics/parameter_definition.rb +230 -0
  23. data/lib/algolia/models/analytics/parameter_reference.rb +219 -0
  24. data/lib/algolia/models/analytics/parameter_value.rb +111 -0
  25. data/lib/algolia/models/analytics/scalar_payload.rb +247 -0
  26. data/lib/algolia/models/analytics/series.rb +234 -0
  27. data/lib/algolia/models/analytics/series_date.rb +223 -0
  28. data/lib/algolia/models/analytics/table_payload.rb +292 -0
  29. data/lib/algolia/models/analytics/table_response.rb +211 -0
  30. data/lib/algolia/models/analytics/timeseries_payload.rb +279 -0
  31. data/lib/algolia/models/analytics/timeseries_response.rb +213 -0
  32. data/lib/algolia/models/insights/added_to_cart_object_ids_after_search.rb +1 -1
  33. data/lib/algolia/models/insights/clicked_object_ids_after_search.rb +1 -1
  34. data/lib/algolia/models/insights/converted_object_ids_after_search.rb +1 -1
  35. data/lib/algolia/models/insights/events_items.rb +1 -0
  36. data/lib/algolia/models/insights/instantsearch.rb +269 -0
  37. data/lib/algolia/models/insights/instantsearch_event.rb +33 -0
  38. data/lib/algolia/models/recommend/facet_filters.rb +109 -0
  39. data/lib/algolia/models/recommend/fallback_params.rb +14 -4
  40. data/lib/algolia/version.rb +1 -1
  41. metadata +26 -2
@@ -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 Analytics
10
+ class DomainCatalog
11
+ # Fields usable as metrics.
12
+ attr_accessor :metrics
13
+
14
+ # Fields usable as filters.
15
+ attr_accessor :filters
16
+
17
+ # Fields usable in `groupBy`.
18
+ attr_accessor :groups
19
+
20
+ # Fields usable in distributions.
21
+ attr_accessor :distributions
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :metrics => :metrics,
27
+ :filters => :filters,
28
+ :groups => :groups,
29
+ :distributions => :distributions
30
+ }
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :metrics => :"Array<CatalogEntry>",
37
+ :filters => :"Array<CatalogEntry>",
38
+ :groups => :"Array<CatalogEntry>",
39
+ :distributions => :"Array<CatalogEntry>"
40
+ }
41
+ end
42
+
43
+ # List of attributes with nullable: true
44
+ def self.openapi_nullable
45
+ Set.new(
46
+ []
47
+ )
48
+ end
49
+
50
+ # Initializes the object
51
+ # @param [Hash] attributes Model attributes in the form of hash
52
+ def initialize(attributes = {})
53
+ if (!attributes.is_a?(Hash))
54
+ raise(
55
+ ArgumentError,
56
+ "The input argument (attributes) must be a hash in `Algolia::DomainCatalog` initialize method"
57
+ )
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ raise(
64
+ ArgumentError,
65
+ "`#{k}` is not a valid attribute in `Algolia::DomainCatalog`. Please check the name to make sure it's valid. List of attributes: " +
66
+ self.class.attribute_map.keys.inspect
67
+ )
68
+ end
69
+
70
+ h[k.to_sym] = v
71
+ }
72
+
73
+ if attributes.key?(:metrics)
74
+ if (value = attributes[:metrics]).is_a?(Array)
75
+ self.metrics = value
76
+ end
77
+ else
78
+ self.metrics = nil
79
+ end
80
+
81
+ if attributes.key?(:filters)
82
+ if (value = attributes[:filters]).is_a?(Array)
83
+ self.filters = value
84
+ end
85
+ else
86
+ self.filters = nil
87
+ end
88
+
89
+ if attributes.key?(:groups)
90
+ if (value = attributes[:groups]).is_a?(Array)
91
+ self.groups = value
92
+ end
93
+ else
94
+ self.groups = nil
95
+ end
96
+
97
+ if attributes.key?(:distributions)
98
+ if (value = attributes[:distributions]).is_a?(Array)
99
+ self.distributions = value
100
+ end
101
+ else
102
+ self.distributions = nil
103
+ end
104
+ end
105
+
106
+ # Checks equality by comparing each attribute.
107
+ # @param [Object] Object to be compared
108
+ def ==(other)
109
+ return true if self.equal?(other)
110
+ self.class == other.class &&
111
+ metrics == other.metrics &&
112
+ filters == other.filters &&
113
+ groups == other.groups &&
114
+ distributions == other.distributions
115
+ end
116
+
117
+ # @see the `==` method
118
+ # @param [Object] Object to be compared
119
+ def eql?(other)
120
+ self == other
121
+ end
122
+
123
+ # Calculates hash code according to all attributes.
124
+ # @return [Integer] Hash code
125
+ def hash
126
+ [metrics, filters, groups, distributions].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
+ return nil unless attributes.is_a?(Hash)
134
+ attributes = attributes.transform_keys(&:to_sym)
135
+ transformed_hash = {}
136
+ types_mapping.each_pair do |key, type|
137
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
138
+ transformed_hash[key.to_sym] = nil
139
+ elsif type =~ /\AArray<(.*)>/i
140
+ # check to ensure the input is an array given that the attribute
141
+ # is documented as an array but the input is not
142
+ if attributes[attribute_map[key]].is_a?(Array)
143
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
144
+ _deserialize(::Regexp.last_match(1), v)
145
+ }
146
+ end
147
+ elsif !attributes[attribute_map[key]].nil?
148
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
149
+ end
150
+ end
151
+
152
+ new(transformed_hash)
153
+ end
154
+
155
+ # Deserializes the data based on type
156
+ # @param string type Data type
157
+ # @param string value Value to be deserialized
158
+ # @return [Object] Deserialized data
159
+ def self._deserialize(type, value)
160
+ case type.to_sym
161
+ when :Time
162
+ Time.parse(value)
163
+ when :Date
164
+ Date.parse(value)
165
+ when :String
166
+ value.to_s
167
+ when :Integer
168
+ value.to_i
169
+ when :Float
170
+ value.to_f
171
+ when :Boolean
172
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
173
+ true
174
+ else
175
+ false
176
+ end
177
+
178
+ when :Object
179
+ # generic object (usually a Hash), return directly
180
+ value
181
+ when /\AArray<(?<inner_type>.+)>\z/
182
+ inner_type = Regexp.last_match[:inner_type]
183
+ value.map { |v| _deserialize(inner_type, v) }
184
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
185
+ k_type = Regexp.last_match[:k_type]
186
+ v_type = Regexp.last_match[:v_type]
187
+ {}.tap do |hash|
188
+ value.each do |k, v|
189
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
190
+ end
191
+ end
192
+ # model
193
+ else
194
+ # models (e.g. Pet) or oneOf
195
+ klass = Algolia::Analytics.const_get(type)
196
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
197
+ .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
+ def to_json(*_args)
214
+ to_hash.to_json
215
+ end
216
+
217
+ # Returns the object in the form of hash
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_hash
220
+ hash = {}
221
+ self.class.attribute_map.each_pair do |attr, param|
222
+ value = send(attr)
223
+ if value.nil?
224
+ is_nullable = self.class.openapi_nullable.include?(attr)
225
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
226
+ end
227
+
228
+ hash[param] = _to_hash(value)
229
+ end
230
+
231
+ hash
232
+ end
233
+
234
+ # Outputs non-array value in the form of hash
235
+ # For object, use to_hash. Otherwise, just return the value
236
+ # @param [Object] value Any valid value
237
+ # @return [Hash] Returns the value in the form of hash
238
+ def _to_hash(value)
239
+ if value.is_a?(Array)
240
+ value.map { |v| _to_hash(v) }
241
+ elsif value.is_a?(Hash)
242
+ {}.tap do |hash|
243
+ value.each { |k, v| hash[k] = _to_hash(v) }
244
+ end
245
+ elsif value.respond_to?(:to_hash)
246
+ value.to_hash
247
+ else
248
+ value
249
+ end
250
+ end
251
+ end
252
+ end
253
+ end
@@ -0,0 +1,219 @@
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 Analytics
10
+ class FieldReference
11
+ # Domain the field belongs to. Defaults to the payload's top-level `domain` when omitted.
12
+ attr_accessor :domain
13
+
14
+ # Field identifier within the domain, as listed by the `/3/patterns/fields` catalog.
15
+ attr_accessor :kind
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :domain => :domain,
21
+ :kind => :kind
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :domain => :"String",
29
+ :kind => :"String"
30
+ }
31
+ end
32
+
33
+ # List of attributes with nullable: true
34
+ def self.openapi_nullable
35
+ Set.new(
36
+ []
37
+ )
38
+ end
39
+
40
+ # Initializes the object
41
+ # @param [Hash] attributes Model attributes in the form of hash
42
+ def initialize(attributes = {})
43
+ if (!attributes.is_a?(Hash))
44
+ raise(
45
+ ArgumentError,
46
+ "The input argument (attributes) must be a hash in `Algolia::FieldReference` initialize method"
47
+ )
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ raise(
54
+ ArgumentError,
55
+ "`#{k}` is not a valid attribute in `Algolia::FieldReference`. Please check the name to make sure it's valid. List of attributes: " +
56
+ self.class.attribute_map.keys.inspect
57
+ )
58
+ end
59
+
60
+ h[k.to_sym] = v
61
+ }
62
+
63
+ if attributes.key?(:domain)
64
+ self.domain = attributes[:domain]
65
+ end
66
+
67
+ if attributes.key?(:kind)
68
+ self.kind = attributes[:kind]
69
+ else
70
+ self.kind = nil
71
+ end
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(other)
77
+ return true if self.equal?(other)
78
+ self.class == other.class &&
79
+ domain == other.domain &&
80
+ kind == other.kind
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(other)
86
+ self == other
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Integer] Hash code
91
+ def hash
92
+ [domain, kind].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def self.build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ attributes = attributes.transform_keys(&:to_sym)
101
+ transformed_hash = {}
102
+ types_mapping.each_pair do |key, type|
103
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
104
+ transformed_hash[key.to_sym] = nil
105
+ elsif type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[attribute_map[key]].is_a?(Array)
109
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
110
+ _deserialize(::Regexp.last_match(1), v)
111
+ }
112
+ end
113
+ elsif !attributes[attribute_map[key]].nil?
114
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
115
+ end
116
+ end
117
+
118
+ new(transformed_hash)
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def self._deserialize(type, value)
126
+ case type.to_sym
127
+ when :Time
128
+ Time.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :Boolean
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
147
+ when /\AArray<(?<inner_type>.+)>\z/
148
+ inner_type = Regexp.last_match[:inner_type]
149
+ value.map { |v| _deserialize(inner_type, v) }
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
151
+ k_type = Regexp.last_match[:k_type]
152
+ v_type = Regexp.last_match[:v_type]
153
+ {}.tap do |hash|
154
+ value.each do |k, v|
155
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
156
+ end
157
+ end
158
+ # model
159
+ else
160
+ # models (e.g. Pet) or oneOf
161
+ klass = Algolia::Analytics.const_get(type)
162
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
163
+ .build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ def to_json(*_args)
180
+ to_hash.to_json
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to?(:to_hash)
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+ end
218
+ end
219
+ end
@@ -0,0 +1,238 @@
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 Analytics
10
+ class FilterDefinition
11
+ # Domain the field belongs to.
12
+ attr_accessor :domain
13
+
14
+ # Field to filter on. With no `operator`, the field must be boolean.
15
+ attr_accessor :kind
16
+
17
+ # Comparison operator applied to a filter field, one of: `=`, `!=`, `>`, `<`, `>=`, `<=`, `IN`, `TAG_TREE`, `CONTAINS`, `STARTS_WITH`, `CONTAINS_PREFIX`. Requires a `parameter` to carry the operand.
18
+ attr_accessor :operator
19
+
20
+ attr_accessor :parameter
21
+
22
+ # Attribute mapping from ruby-style variable name to JSON key.
23
+ def self.attribute_map
24
+ {
25
+ :domain => :domain,
26
+ :kind => :kind,
27
+ :operator => :operator,
28
+ :parameter => :parameter
29
+ }
30
+ end
31
+
32
+ # Attribute type mapping.
33
+ def self.types_mapping
34
+ {
35
+ :domain => :"String",
36
+ :kind => :"String",
37
+ :operator => :"String",
38
+ :parameter => :"ParameterReference"
39
+ }
40
+ end
41
+
42
+ # List of attributes with nullable: true
43
+ def self.openapi_nullable
44
+ Set.new(
45
+ []
46
+ )
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ if (!attributes.is_a?(Hash))
53
+ raise(
54
+ ArgumentError,
55
+ "The input argument (attributes) must be a hash in `Algolia::FilterDefinition` initialize method"
56
+ )
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ raise(
63
+ ArgumentError,
64
+ "`#{k}` is not a valid attribute in `Algolia::FilterDefinition`. Please check the name to make sure it's valid. List of attributes: " +
65
+ self.class.attribute_map.keys.inspect
66
+ )
67
+ end
68
+
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:domain)
73
+ self.domain = attributes[:domain]
74
+ end
75
+
76
+ if attributes.key?(:kind)
77
+ self.kind = attributes[:kind]
78
+ else
79
+ self.kind = nil
80
+ end
81
+
82
+ if attributes.key?(:operator)
83
+ self.operator = attributes[:operator]
84
+ end
85
+
86
+ if attributes.key?(:parameter)
87
+ self.parameter = attributes[:parameter]
88
+ end
89
+ end
90
+
91
+ # Checks equality by comparing each attribute.
92
+ # @param [Object] Object to be compared
93
+ def ==(other)
94
+ return true if self.equal?(other)
95
+ self.class == other.class &&
96
+ domain == other.domain &&
97
+ kind == other.kind &&
98
+ operator == other.operator &&
99
+ parameter == other.parameter
100
+ end
101
+
102
+ # @see the `==` method
103
+ # @param [Object] Object to be compared
104
+ def eql?(other)
105
+ self == other
106
+ end
107
+
108
+ # Calculates hash code according to all attributes.
109
+ # @return [Integer] Hash code
110
+ def hash
111
+ [domain, kind, operator, parameter].hash
112
+ end
113
+
114
+ # Builds the object from hash
115
+ # @param [Hash] attributes Model attributes in the form of hash
116
+ # @return [Object] Returns the model itself
117
+ def self.build_from_hash(attributes)
118
+ return nil unless attributes.is_a?(Hash)
119
+ attributes = attributes.transform_keys(&:to_sym)
120
+ transformed_hash = {}
121
+ types_mapping.each_pair do |key, type|
122
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
123
+ transformed_hash[key.to_sym] = nil
124
+ elsif type =~ /\AArray<(.*)>/i
125
+ # check to ensure the input is an array given that the attribute
126
+ # is documented as an array but the input is not
127
+ if attributes[attribute_map[key]].is_a?(Array)
128
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
129
+ _deserialize(::Regexp.last_match(1), v)
130
+ }
131
+ end
132
+ elsif !attributes[attribute_map[key]].nil?
133
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
134
+ end
135
+ end
136
+
137
+ new(transformed_hash)
138
+ end
139
+
140
+ # Deserializes the data based on type
141
+ # @param string type Data type
142
+ # @param string value Value to be deserialized
143
+ # @return [Object] Deserialized data
144
+ def self._deserialize(type, value)
145
+ case type.to_sym
146
+ when :Time
147
+ Time.parse(value)
148
+ when :Date
149
+ Date.parse(value)
150
+ when :String
151
+ value.to_s
152
+ when :Integer
153
+ value.to_i
154
+ when :Float
155
+ value.to_f
156
+ when :Boolean
157
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
158
+ true
159
+ else
160
+ false
161
+ end
162
+
163
+ when :Object
164
+ # generic object (usually a Hash), return directly
165
+ value
166
+ when /\AArray<(?<inner_type>.+)>\z/
167
+ inner_type = Regexp.last_match[:inner_type]
168
+ value.map { |v| _deserialize(inner_type, v) }
169
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
170
+ k_type = Regexp.last_match[:k_type]
171
+ v_type = Regexp.last_match[:v_type]
172
+ {}.tap do |hash|
173
+ value.each do |k, v|
174
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
175
+ end
176
+ end
177
+ # model
178
+ else
179
+ # models (e.g. Pet) or oneOf
180
+ klass = Algolia::Analytics.const_get(type)
181
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
182
+ .build_from_hash(value)
183
+ end
184
+ end
185
+
186
+ # Returns the string representation of the object
187
+ # @return [String] String presentation of the object
188
+ def to_s
189
+ to_hash.to_s
190
+ end
191
+
192
+ # to_body is an alias to to_hash (backward compatibility)
193
+ # @return [Hash] Returns the object in the form of hash
194
+ def to_body
195
+ to_hash
196
+ end
197
+
198
+ def to_json(*_args)
199
+ to_hash.to_json
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = send(attr)
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
213
+ hash[param] = _to_hash(value)
214
+ end
215
+
216
+ hash
217
+ end
218
+
219
+ # Outputs non-array value in the form of hash
220
+ # For object, use to_hash. Otherwise, just return the value
221
+ # @param [Object] value Any valid value
222
+ # @return [Hash] Returns the value in the form of hash
223
+ def _to_hash(value)
224
+ if value.is_a?(Array)
225
+ value.map { |v| _to_hash(v) }
226
+ elsif value.is_a?(Hash)
227
+ {}.tap do |hash|
228
+ value.each { |k, v| hash[k] = _to_hash(v) }
229
+ end
230
+ elsif value.respond_to?(:to_hash)
231
+ value.to_hash
232
+ else
233
+ value
234
+ end
235
+ end
236
+ end
237
+ end
238
+ end