algolia 3.22.1 → 3.23.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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -1
  3. data/CHANGELOG.md +5 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/abtesting_v3_client.rb +638 -0
  6. data/lib/algolia/models/abtesting-v3/ab_test.rb +300 -0
  7. data/lib/algolia/models/abtesting-v3/ab_test_configuration.rb +230 -0
  8. data/lib/algolia/models/abtesting-v3/ab_test_response.rb +235 -0
  9. data/lib/algolia/models/abtesting-v3/ab_tests_variant.rb +233 -0
  10. data/lib/algolia/models/abtesting-v3/ab_tests_variant_search_params.rb +259 -0
  11. data/lib/algolia/models/abtesting-v3/add_ab_tests_request.rb +260 -0
  12. data/lib/algolia/models/abtesting-v3/add_ab_tests_variant.rb +109 -0
  13. data/lib/algolia/models/abtesting-v3/create_metric.rb +222 -0
  14. data/lib/algolia/models/abtesting-v3/direction.rb +34 -0
  15. data/lib/algolia/models/abtesting-v3/effect_metric.rb +37 -0
  16. data/lib/algolia/models/abtesting-v3/empty_search_filter.rb +220 -0
  17. data/lib/algolia/models/abtesting-v3/error_base.rb +209 -0
  18. data/lib/algolia/models/abtesting-v3/error_correction_type.rb +34 -0
  19. data/lib/algolia/models/abtesting-v3/estimate_ab_test_request.rb +224 -0
  20. data/lib/algolia/models/abtesting-v3/estimate_ab_test_response.rb +221 -0
  21. data/lib/algolia/models/abtesting-v3/estimate_configuration.rb +223 -0
  22. data/lib/algolia/models/abtesting-v3/filter_effects.rb +218 -0
  23. data/lib/algolia/models/abtesting-v3/list_ab_tests_response.rb +239 -0
  24. data/lib/algolia/models/abtesting-v3/metric_date.rb +221 -0
  25. data/lib/algolia/models/abtesting-v3/metric_metadata.rb +220 -0
  26. data/lib/algolia/models/abtesting-v3/metric_name.rb +63 -0
  27. data/lib/algolia/models/abtesting-v3/metric_result.rb +315 -0
  28. data/lib/algolia/models/abtesting-v3/metrics_filter.rb +244 -0
  29. data/lib/algolia/models/abtesting-v3/minimum_detectable_effect.rb +223 -0
  30. data/lib/algolia/models/abtesting-v3/outliers_filter.rb +220 -0
  31. data/lib/algolia/models/abtesting-v3/schedule_ab_test_response.rb +211 -0
  32. data/lib/algolia/models/abtesting-v3/schedule_ab_tests_request.rb +272 -0
  33. data/lib/algolia/models/abtesting-v3/status.rb +36 -0
  34. data/lib/algolia/models/abtesting-v3/timeseries.rb +225 -0
  35. data/lib/algolia/models/abtesting-v3/timeseries_variant.rb +210 -0
  36. data/lib/algolia/models/abtesting-v3/variant.rb +275 -0
  37. data/lib/algolia/models/abtesting-v3/variant_metadata.rb +209 -0
  38. data/lib/algolia/version.rb +1 -1
  39. metadata +34 -1
@@ -0,0 +1,223 @@
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 AbtestingV3
10
+ # A/B test configuration for estimating the sample size and duration using minimum detectable effect.
11
+ class EstimateConfiguration
12
+ # List of metric filters applied to the test population.
13
+ attr_accessor :filters
14
+
15
+ attr_accessor :minimum_detectable_effect
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :filters => :filters,
21
+ :minimum_detectable_effect => :minimumDetectableEffect
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :filters => :"Array<MetricsFilter>",
29
+ :minimum_detectable_effect => :"MinimumDetectableEffect"
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::EstimateConfiguration` 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::EstimateConfiguration`. 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?(:filters)
64
+ if (value = attributes[:filters]).is_a?(Array)
65
+ self.filters = value
66
+ end
67
+ end
68
+
69
+ if attributes.key?(:minimum_detectable_effect)
70
+ self.minimum_detectable_effect = attributes[:minimum_detectable_effect]
71
+ else
72
+ self.minimum_detectable_effect = nil
73
+ end
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(other)
79
+ return true if self.equal?(other)
80
+ self.class == other.class &&
81
+ filters == other.filters &&
82
+ minimum_detectable_effect == other.minimum_detectable_effect
83
+ end
84
+
85
+ # @see the `==` method
86
+ # @param [Object] Object to be compared
87
+ def eql?(other)
88
+ self == other
89
+ end
90
+
91
+ # Calculates hash code according to all attributes.
92
+ # @return [Integer] Hash code
93
+ def hash
94
+ [filters, minimum_detectable_effect].hash
95
+ end
96
+
97
+ # Builds the object from hash
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ # @return [Object] Returns the model itself
100
+ def self.build_from_hash(attributes)
101
+ return nil unless attributes.is_a?(Hash)
102
+ attributes = attributes.transform_keys(&:to_sym)
103
+ transformed_hash = {}
104
+ types_mapping.each_pair do |key, type|
105
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
106
+ transformed_hash[key.to_sym] = nil
107
+ elsif type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[attribute_map[key]].is_a?(Array)
111
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
112
+ _deserialize(::Regexp.last_match(1), v)
113
+ }
114
+ end
115
+ elsif !attributes[attribute_map[key]].nil?
116
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
117
+ end
118
+ end
119
+
120
+ new(transformed_hash)
121
+ end
122
+
123
+ # Deserializes the data based on type
124
+ # @param string type Data type
125
+ # @param string value Value to be deserialized
126
+ # @return [Object] Deserialized data
127
+ def self._deserialize(type, value)
128
+ case type.to_sym
129
+ when :Time
130
+ Time.parse(value)
131
+ when :Date
132
+ Date.parse(value)
133
+ when :String
134
+ value.to_s
135
+ when :Integer
136
+ value.to_i
137
+ when :Float
138
+ value.to_f
139
+ when :Boolean
140
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
141
+ true
142
+ else
143
+ false
144
+ end
145
+
146
+ when :Object
147
+ # generic object (usually a Hash), return directly
148
+ value
149
+ when /\AArray<(?<inner_type>.+)>\z/
150
+ inner_type = Regexp.last_match[:inner_type]
151
+ value.map { |v| _deserialize(inner_type, v) }
152
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
153
+ k_type = Regexp.last_match[:k_type]
154
+ v_type = Regexp.last_match[:v_type]
155
+ {}.tap do |hash|
156
+ value.each do |k, v|
157
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
158
+ end
159
+ end
160
+ # model
161
+ else
162
+ # models (e.g. Pet) or oneOf
163
+ klass = Algolia::AbtestingV3.const_get(type)
164
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
165
+ .build_from_hash(value)
166
+ end
167
+ end
168
+
169
+ # Returns the string representation of the object
170
+ # @return [String] String presentation of the object
171
+ def to_s
172
+ to_hash.to_s
173
+ end
174
+
175
+ # to_body is an alias to to_hash (backward compatibility)
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_body
178
+ to_hash
179
+ end
180
+
181
+ def to_json(*_args)
182
+ to_hash.to_json
183
+ end
184
+
185
+ # Returns the object in the form of hash
186
+ # @return [Hash] Returns the object in the form of hash
187
+ def to_hash
188
+ hash = {}
189
+ self.class.attribute_map.each_pair do |attr, param|
190
+ value = send(attr)
191
+ if value.nil?
192
+ is_nullable = self.class.openapi_nullable.include?(attr)
193
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
194
+ end
195
+
196
+ hash[param] = _to_hash(value)
197
+ end
198
+
199
+ hash
200
+ end
201
+
202
+ # Outputs non-array value in the form of hash
203
+ # For object, use to_hash. Otherwise, just return the value
204
+ # @param [Object] value Any valid value
205
+ # @return [Hash] Returns the value in the form of hash
206
+ def _to_hash(value)
207
+ if value.is_a?(Array)
208
+ value.compact.map { |v| _to_hash(v) }
209
+ elsif value.is_a?(Hash)
210
+ {}.tap do |hash|
211
+ value.each { |k, v| hash[k] = _to_hash(v) }
212
+ end
213
+ elsif value.respond_to?(:to_hash)
214
+ value.to_hash
215
+ else
216
+ value
217
+ end
218
+ end
219
+
220
+ end
221
+
222
+ end
223
+ end
@@ -0,0 +1,218 @@
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 AbtestingV3
10
+ # A/B test filter effects resulting from configuration settings.
11
+ class FilterEffects
12
+ attr_accessor :outliers
13
+
14
+ attr_accessor :empty_search
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :outliers => :outliers,
20
+ :empty_search => :emptySearch
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.types_mapping
26
+ {
27
+ :outliers => :"OutliersFilter",
28
+ :empty_search => :"EmptySearchFilter"
29
+ }
30
+ end
31
+
32
+ # List of attributes with nullable: true
33
+ def self.openapi_nullable
34
+ Set.new(
35
+ []
36
+ )
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ raise(
44
+ ArgumentError,
45
+ "The input argument (attributes) must be a hash in `Algolia::FilterEffects` initialize method"
46
+ )
47
+ end
48
+
49
+ # check to see if the attribute exists and convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) { |(k, v), h|
51
+ if (!self.class.attribute_map.key?(k.to_sym))
52
+ raise(
53
+ ArgumentError,
54
+ "`#{k}` is not a valid attribute in `Algolia::FilterEffects`. Please check the name to make sure it's valid. List of attributes: " +
55
+ self.class.attribute_map.keys.inspect
56
+ )
57
+ end
58
+
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:outliers)
63
+ self.outliers = attributes[:outliers]
64
+ end
65
+
66
+ if attributes.key?(:empty_search)
67
+ self.empty_search = attributes[:empty_search]
68
+ end
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(other)
74
+ return true if self.equal?(other)
75
+ self.class == other.class &&
76
+ outliers == other.outliers &&
77
+ empty_search == other.empty_search
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(other)
83
+ self == other
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Integer] Hash code
88
+ def hash
89
+ [outliers, empty_search].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def self.build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ attributes = attributes.transform_keys(&:to_sym)
98
+ transformed_hash = {}
99
+ types_mapping.each_pair do |key, type|
100
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
101
+ transformed_hash[key.to_sym] = nil
102
+ elsif type =~ /\AArray<(.*)>/i
103
+ # check to ensure the input is an array given that the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[attribute_map[key]].is_a?(Array)
106
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
107
+ _deserialize(::Regexp.last_match(1), v)
108
+ }
109
+ end
110
+ elsif !attributes[attribute_map[key]].nil?
111
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
112
+ end
113
+ end
114
+
115
+ new(transformed_hash)
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def self._deserialize(type, value)
123
+ case type.to_sym
124
+ when :Time
125
+ Time.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :Boolean
135
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ # model
156
+ else
157
+ # models (e.g. Pet) or oneOf
158
+ klass = Algolia::AbtestingV3.const_get(type)
159
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
160
+ .build_from_hash(value)
161
+ end
162
+ end
163
+
164
+ # Returns the string representation of the object
165
+ # @return [String] String presentation of the object
166
+ def to_s
167
+ to_hash.to_s
168
+ end
169
+
170
+ # to_body is an alias to to_hash (backward compatibility)
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_body
173
+ to_hash
174
+ end
175
+
176
+ def to_json(*_args)
177
+ to_hash.to_json
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = send(attr)
186
+ if value.nil?
187
+ is_nullable = self.class.openapi_nullable.include?(attr)
188
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
+ end
190
+
191
+ hash[param] = _to_hash(value)
192
+ end
193
+
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map { |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to?(:to_hash)
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+
217
+ end
218
+ end
@@ -0,0 +1,239 @@
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 AbtestingV3
10
+ class ListABTestsResponse
11
+ # A/B tests.
12
+ attr_accessor :abtests
13
+
14
+ # Number of A/B tests.
15
+ attr_accessor :count
16
+
17
+ # Number of retrievable A/B tests.
18
+ attr_accessor :total
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :abtests => :abtests,
24
+ :count => :count,
25
+ :total => :total
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.types_mapping
31
+ {
32
+ :abtests => :"Array<ABTest>",
33
+ :count => :"Integer",
34
+ :total => :"Integer"
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new(
41
+ [
42
+ :abtests
43
+ ]
44
+ )
45
+ end
46
+
47
+ # Initializes the object
48
+ # @param [Hash] attributes Model attributes in the form of hash
49
+ def initialize(attributes = {})
50
+ if (!attributes.is_a?(Hash))
51
+ raise(
52
+ ArgumentError,
53
+ "The input argument (attributes) must be a hash in `Algolia::ListABTestsResponse` initialize method"
54
+ )
55
+ end
56
+
57
+ # check to see if the attribute exists and convert string to symbol for hash key
58
+ attributes = attributes.each_with_object({}) { |(k, v), h|
59
+ if (!self.class.attribute_map.key?(k.to_sym))
60
+ raise(
61
+ ArgumentError,
62
+ "`#{k}` is not a valid attribute in `Algolia::ListABTestsResponse`. Please check the name to make sure it's valid. List of attributes: " +
63
+ self.class.attribute_map.keys.inspect
64
+ )
65
+ end
66
+
67
+ h[k.to_sym] = v
68
+ }
69
+
70
+ if attributes.key?(:abtests)
71
+ if (value = attributes[:abtests]).is_a?(Array)
72
+ self.abtests = value
73
+ end
74
+ else
75
+ self.abtests = nil
76
+ end
77
+
78
+ if attributes.key?(:count)
79
+ self.count = attributes[:count]
80
+ else
81
+ self.count = nil
82
+ end
83
+
84
+ if attributes.key?(:total)
85
+ self.total = attributes[:total]
86
+ else
87
+ self.total = nil
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
+ abtests == other.abtests &&
97
+ count == other.count &&
98
+ total == other.total
99
+ end
100
+
101
+ # @see the `==` method
102
+ # @param [Object] Object to be compared
103
+ def eql?(other)
104
+ self == other
105
+ end
106
+
107
+ # Calculates hash code according to all attributes.
108
+ # @return [Integer] Hash code
109
+ def hash
110
+ [abtests, count, total].hash
111
+ end
112
+
113
+ # Builds the object from hash
114
+ # @param [Hash] attributes Model attributes in the form of hash
115
+ # @return [Object] Returns the model itself
116
+ def self.build_from_hash(attributes)
117
+ return nil unless attributes.is_a?(Hash)
118
+ attributes = attributes.transform_keys(&:to_sym)
119
+ transformed_hash = {}
120
+ types_mapping.each_pair do |key, type|
121
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
122
+ transformed_hash[key.to_sym] = nil
123
+ elsif type =~ /\AArray<(.*)>/i
124
+ # check to ensure the input is an array given that the attribute
125
+ # is documented as an array but the input is not
126
+ if attributes[attribute_map[key]].is_a?(Array)
127
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
128
+ _deserialize(::Regexp.last_match(1), v)
129
+ }
130
+ end
131
+ elsif !attributes[attribute_map[key]].nil?
132
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
133
+ end
134
+ end
135
+
136
+ new(transformed_hash)
137
+ end
138
+
139
+ # Deserializes the data based on type
140
+ # @param string type Data type
141
+ # @param string value Value to be deserialized
142
+ # @return [Object] Deserialized data
143
+ def self._deserialize(type, value)
144
+ case type.to_sym
145
+ when :Time
146
+ Time.parse(value)
147
+ when :Date
148
+ Date.parse(value)
149
+ when :String
150
+ value.to_s
151
+ when :Integer
152
+ value.to_i
153
+ when :Float
154
+ value.to_f
155
+ when :Boolean
156
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
157
+ true
158
+ else
159
+ false
160
+ end
161
+
162
+ when :Object
163
+ # generic object (usually a Hash), return directly
164
+ value
165
+ when /\AArray<(?<inner_type>.+)>\z/
166
+ inner_type = Regexp.last_match[:inner_type]
167
+ value.map { |v| _deserialize(inner_type, v) }
168
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
169
+ k_type = Regexp.last_match[:k_type]
170
+ v_type = Regexp.last_match[:v_type]
171
+ {}.tap do |hash|
172
+ value.each do |k, v|
173
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
174
+ end
175
+ end
176
+ # model
177
+ else
178
+ # models (e.g. Pet) or oneOf
179
+ klass = Algolia::AbtestingV3.const_get(type)
180
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
181
+ .build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ def to_json(*_args)
198
+ to_hash.to_json
199
+ end
200
+
201
+ # Returns the object in the form of hash
202
+ # @return [Hash] Returns the object in the form of hash
203
+ def to_hash
204
+ hash = {}
205
+ self.class.attribute_map.each_pair do |attr, param|
206
+ value = send(attr)
207
+ if value.nil?
208
+ is_nullable = self.class.openapi_nullable.include?(attr)
209
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
210
+ end
211
+
212
+ hash[param] = _to_hash(value)
213
+ end
214
+
215
+ hash
216
+ end
217
+
218
+ # Outputs non-array value in the form of hash
219
+ # For object, use to_hash. Otherwise, just return the value
220
+ # @param [Object] value Any valid value
221
+ # @return [Hash] Returns the value in the form of hash
222
+ def _to_hash(value)
223
+ if value.is_a?(Array)
224
+ value.compact.map { |v| _to_hash(v) }
225
+ elsif value.is_a?(Hash)
226
+ {}.tap do |hash|
227
+ value.each { |k, v| hash[k] = _to_hash(v) }
228
+ end
229
+ elsif value.respond_to?(:to_hash)
230
+ value.to_hash
231
+ else
232
+ value
233
+ end
234
+ end
235
+
236
+ end
237
+
238
+ end
239
+ end