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.
- checksums.yaml +4 -4
- data/.github/workflows/release.yml +1 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/abtesting_v3_client.rb +638 -0
- data/lib/algolia/models/abtesting-v3/ab_test.rb +300 -0
- data/lib/algolia/models/abtesting-v3/ab_test_configuration.rb +230 -0
- data/lib/algolia/models/abtesting-v3/ab_test_response.rb +235 -0
- data/lib/algolia/models/abtesting-v3/ab_tests_variant.rb +233 -0
- data/lib/algolia/models/abtesting-v3/ab_tests_variant_search_params.rb +259 -0
- data/lib/algolia/models/abtesting-v3/add_ab_tests_request.rb +260 -0
- data/lib/algolia/models/abtesting-v3/add_ab_tests_variant.rb +109 -0
- data/lib/algolia/models/abtesting-v3/create_metric.rb +222 -0
- data/lib/algolia/models/abtesting-v3/direction.rb +34 -0
- data/lib/algolia/models/abtesting-v3/effect_metric.rb +37 -0
- data/lib/algolia/models/abtesting-v3/empty_search_filter.rb +220 -0
- data/lib/algolia/models/abtesting-v3/error_base.rb +209 -0
- data/lib/algolia/models/abtesting-v3/error_correction_type.rb +34 -0
- data/lib/algolia/models/abtesting-v3/estimate_ab_test_request.rb +224 -0
- data/lib/algolia/models/abtesting-v3/estimate_ab_test_response.rb +221 -0
- data/lib/algolia/models/abtesting-v3/estimate_configuration.rb +223 -0
- data/lib/algolia/models/abtesting-v3/filter_effects.rb +218 -0
- data/lib/algolia/models/abtesting-v3/list_ab_tests_response.rb +239 -0
- data/lib/algolia/models/abtesting-v3/metric_date.rb +221 -0
- data/lib/algolia/models/abtesting-v3/metric_metadata.rb +220 -0
- data/lib/algolia/models/abtesting-v3/metric_name.rb +63 -0
- data/lib/algolia/models/abtesting-v3/metric_result.rb +315 -0
- data/lib/algolia/models/abtesting-v3/metrics_filter.rb +244 -0
- data/lib/algolia/models/abtesting-v3/minimum_detectable_effect.rb +223 -0
- data/lib/algolia/models/abtesting-v3/outliers_filter.rb +220 -0
- data/lib/algolia/models/abtesting-v3/schedule_ab_test_response.rb +211 -0
- data/lib/algolia/models/abtesting-v3/schedule_ab_tests_request.rb +272 -0
- data/lib/algolia/models/abtesting-v3/status.rb +36 -0
- data/lib/algolia/models/abtesting-v3/timeseries.rb +225 -0
- data/lib/algolia/models/abtesting-v3/timeseries_variant.rb +210 -0
- data/lib/algolia/models/abtesting-v3/variant.rb +275 -0
- data/lib/algolia/models/abtesting-v3/variant_metadata.rb +209 -0
- data/lib/algolia/version.rb +1 -1
- metadata +34 -1
@@ -0,0 +1,315 @@
|
|
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 MetricResult
|
11
|
+
attr_accessor :name
|
12
|
+
|
13
|
+
# Date and time when the metric was last updated, in RFC 3339 format.
|
14
|
+
attr_accessor :updated_at
|
15
|
+
|
16
|
+
attr_accessor :value
|
17
|
+
|
18
|
+
# The upper bound of the 95% confidence interval for the metric value. The confidence interval is calculated using either the relative ratio or relative difference between the metric values for the control and the variant. Relative ratio is used for metrics that are ratios (e.g., click-through rate, conversion rate), while relative difference is used for continuous metrics (e.g., revenue).
|
19
|
+
attr_accessor :value_ci_high
|
20
|
+
|
21
|
+
# The lower bound of the 95% confidence interval for the metric value. The confidence interval is calculated using either the relative ratio or relative difference between the metric values for the control and the variant. Relative ratio is used for metrics that are ratios (e.g., click-through rate, conversion rate), while relative difference is used for continuous metrics (e.g., revenue).
|
22
|
+
attr_accessor :value_ci_low
|
23
|
+
|
24
|
+
# PValue for the first variant (control) will always be 0. For the other variants, pValue is calculated for the current variant based on the control.
|
25
|
+
attr_accessor :p_value
|
26
|
+
|
27
|
+
# Dimension defined during test creation.
|
28
|
+
attr_accessor :dimension
|
29
|
+
|
30
|
+
attr_accessor :metadata
|
31
|
+
|
32
|
+
# The value that was computed during error correction. It is used to determine significance of the metric pValue. The critical value is calculated using Bonferroni or Benjamini-Hochberg corrections, based on the given configuration during the A/B test creation.
|
33
|
+
attr_accessor :critical_value
|
34
|
+
|
35
|
+
# Whether the pValue is significant or not based on the critical value and the error correction algorithm used.
|
36
|
+
attr_accessor :significant
|
37
|
+
|
38
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
39
|
+
def self.attribute_map
|
40
|
+
{
|
41
|
+
:name => :name,
|
42
|
+
:updated_at => :updatedAt,
|
43
|
+
:value => :value,
|
44
|
+
:value_ci_high => :valueCIHigh,
|
45
|
+
:value_ci_low => :valueCILow,
|
46
|
+
:p_value => :pValue,
|
47
|
+
:dimension => :dimension,
|
48
|
+
:metadata => :metadata,
|
49
|
+
:critical_value => :criticalValue,
|
50
|
+
:significant => :significant
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
# Attribute type mapping.
|
55
|
+
def self.types_mapping
|
56
|
+
{
|
57
|
+
:name => :"String",
|
58
|
+
:updated_at => :"String",
|
59
|
+
:value => :"Float",
|
60
|
+
:value_ci_high => :"Float",
|
61
|
+
:value_ci_low => :"Float",
|
62
|
+
:p_value => :"Float",
|
63
|
+
:dimension => :"String",
|
64
|
+
:metadata => :"MetricMetadata",
|
65
|
+
:critical_value => :"Float",
|
66
|
+
:significant => :"Boolean"
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
# List of attributes with nullable: true
|
71
|
+
def self.openapi_nullable
|
72
|
+
Set.new(
|
73
|
+
[]
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Initializes the object
|
78
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
79
|
+
def initialize(attributes = {})
|
80
|
+
if (!attributes.is_a?(Hash))
|
81
|
+
raise(
|
82
|
+
ArgumentError,
|
83
|
+
"The input argument (attributes) must be a hash in `Algolia::MetricResult` initialize method"
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
88
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
89
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
90
|
+
raise(
|
91
|
+
ArgumentError,
|
92
|
+
"`#{k}` is not a valid attribute in `Algolia::MetricResult`. Please check the name to make sure it's valid. List of attributes: " +
|
93
|
+
self.class.attribute_map.keys.inspect
|
94
|
+
)
|
95
|
+
end
|
96
|
+
|
97
|
+
h[k.to_sym] = v
|
98
|
+
}
|
99
|
+
|
100
|
+
if attributes.key?(:name)
|
101
|
+
self.name = attributes[:name]
|
102
|
+
else
|
103
|
+
self.name = nil
|
104
|
+
end
|
105
|
+
|
106
|
+
if attributes.key?(:updated_at)
|
107
|
+
self.updated_at = attributes[:updated_at]
|
108
|
+
else
|
109
|
+
self.updated_at = nil
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:value)
|
113
|
+
self.value = attributes[:value]
|
114
|
+
else
|
115
|
+
self.value = nil
|
116
|
+
end
|
117
|
+
|
118
|
+
if attributes.key?(:value_ci_high)
|
119
|
+
self.value_ci_high = attributes[:value_ci_high]
|
120
|
+
end
|
121
|
+
|
122
|
+
if attributes.key?(:value_ci_low)
|
123
|
+
self.value_ci_low = attributes[:value_ci_low]
|
124
|
+
end
|
125
|
+
|
126
|
+
if attributes.key?(:p_value)
|
127
|
+
self.p_value = attributes[:p_value]
|
128
|
+
else
|
129
|
+
self.p_value = nil
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:dimension)
|
133
|
+
self.dimension = attributes[:dimension]
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:metadata)
|
137
|
+
self.metadata = attributes[:metadata]
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:critical_value)
|
141
|
+
self.critical_value = attributes[:critical_value]
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:significant)
|
145
|
+
self.significant = attributes[:significant]
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Checks equality by comparing each attribute.
|
150
|
+
# @param [Object] Object to be compared
|
151
|
+
def ==(other)
|
152
|
+
return true if self.equal?(other)
|
153
|
+
self.class == other.class &&
|
154
|
+
name == other.name &&
|
155
|
+
updated_at == other.updated_at &&
|
156
|
+
value == other.value &&
|
157
|
+
value_ci_high == other.value_ci_high &&
|
158
|
+
value_ci_low == other.value_ci_low &&
|
159
|
+
p_value == other.p_value &&
|
160
|
+
dimension == other.dimension &&
|
161
|
+
metadata == other.metadata &&
|
162
|
+
critical_value == other.critical_value &&
|
163
|
+
significant == other.significant
|
164
|
+
end
|
165
|
+
|
166
|
+
# @see the `==` method
|
167
|
+
# @param [Object] Object to be compared
|
168
|
+
def eql?(other)
|
169
|
+
self == other
|
170
|
+
end
|
171
|
+
|
172
|
+
# Calculates hash code according to all attributes.
|
173
|
+
# @return [Integer] Hash code
|
174
|
+
def hash
|
175
|
+
[
|
176
|
+
name,
|
177
|
+
updated_at,
|
178
|
+
value,
|
179
|
+
value_ci_high,
|
180
|
+
value_ci_low,
|
181
|
+
p_value,
|
182
|
+
dimension,
|
183
|
+
metadata,
|
184
|
+
critical_value,
|
185
|
+
significant
|
186
|
+
].hash
|
187
|
+
end
|
188
|
+
|
189
|
+
# Builds the object from hash
|
190
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
191
|
+
# @return [Object] Returns the model itself
|
192
|
+
def self.build_from_hash(attributes)
|
193
|
+
return nil unless attributes.is_a?(Hash)
|
194
|
+
attributes = attributes.transform_keys(&:to_sym)
|
195
|
+
transformed_hash = {}
|
196
|
+
types_mapping.each_pair do |key, type|
|
197
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
198
|
+
transformed_hash[key.to_sym] = nil
|
199
|
+
elsif type =~ /\AArray<(.*)>/i
|
200
|
+
# check to ensure the input is an array given that the attribute
|
201
|
+
# is documented as an array but the input is not
|
202
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
203
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
204
|
+
_deserialize(::Regexp.last_match(1), v)
|
205
|
+
}
|
206
|
+
end
|
207
|
+
elsif !attributes[attribute_map[key]].nil?
|
208
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
new(transformed_hash)
|
213
|
+
end
|
214
|
+
|
215
|
+
# Deserializes the data based on type
|
216
|
+
# @param string type Data type
|
217
|
+
# @param string value Value to be deserialized
|
218
|
+
# @return [Object] Deserialized data
|
219
|
+
def self._deserialize(type, value)
|
220
|
+
case type.to_sym
|
221
|
+
when :Time
|
222
|
+
Time.parse(value)
|
223
|
+
when :Date
|
224
|
+
Date.parse(value)
|
225
|
+
when :String
|
226
|
+
value.to_s
|
227
|
+
when :Integer
|
228
|
+
value.to_i
|
229
|
+
when :Float
|
230
|
+
value.to_f
|
231
|
+
when :Boolean
|
232
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
233
|
+
true
|
234
|
+
else
|
235
|
+
false
|
236
|
+
end
|
237
|
+
|
238
|
+
when :Object
|
239
|
+
# generic object (usually a Hash), return directly
|
240
|
+
value
|
241
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
242
|
+
inner_type = Regexp.last_match[:inner_type]
|
243
|
+
value.map { |v| _deserialize(inner_type, v) }
|
244
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
245
|
+
k_type = Regexp.last_match[:k_type]
|
246
|
+
v_type = Regexp.last_match[:v_type]
|
247
|
+
{}.tap do |hash|
|
248
|
+
value.each do |k, v|
|
249
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
# model
|
253
|
+
else
|
254
|
+
# models (e.g. Pet) or oneOf
|
255
|
+
klass = Algolia::AbtestingV3.const_get(type)
|
256
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
257
|
+
.build_from_hash(value)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
|
261
|
+
# Returns the string representation of the object
|
262
|
+
# @return [String] String presentation of the object
|
263
|
+
def to_s
|
264
|
+
to_hash.to_s
|
265
|
+
end
|
266
|
+
|
267
|
+
# to_body is an alias to to_hash (backward compatibility)
|
268
|
+
# @return [Hash] Returns the object in the form of hash
|
269
|
+
def to_body
|
270
|
+
to_hash
|
271
|
+
end
|
272
|
+
|
273
|
+
def to_json(*_args)
|
274
|
+
to_hash.to_json
|
275
|
+
end
|
276
|
+
|
277
|
+
# Returns the object in the form of hash
|
278
|
+
# @return [Hash] Returns the object in the form of hash
|
279
|
+
def to_hash
|
280
|
+
hash = {}
|
281
|
+
self.class.attribute_map.each_pair do |attr, param|
|
282
|
+
value = send(attr)
|
283
|
+
if value.nil?
|
284
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
285
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
286
|
+
end
|
287
|
+
|
288
|
+
hash[param] = _to_hash(value)
|
289
|
+
end
|
290
|
+
|
291
|
+
hash
|
292
|
+
end
|
293
|
+
|
294
|
+
# Outputs non-array value in the form of hash
|
295
|
+
# For object, use to_hash. Otherwise, just return the value
|
296
|
+
# @param [Object] value Any valid value
|
297
|
+
# @return [Hash] Returns the value in the form of hash
|
298
|
+
def _to_hash(value)
|
299
|
+
if value.is_a?(Array)
|
300
|
+
value.compact.map { |v| _to_hash(v) }
|
301
|
+
elsif value.is_a?(Hash)
|
302
|
+
{}.tap do |hash|
|
303
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
304
|
+
end
|
305
|
+
elsif value.respond_to?(:to_hash)
|
306
|
+
value.to_hash
|
307
|
+
else
|
308
|
+
value
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
|
+
end
|
@@ -0,0 +1,244 @@
|
|
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
|
+
# Boolean filter applied to the A/B test population. Each filter targets a boolean metric and decides whether to include (true) or exclude (false) matching records.
|
11
|
+
class MetricsFilter
|
12
|
+
# Metric domain (for example `abtesting`, `personalization`).
|
13
|
+
attr_accessor :domain
|
14
|
+
|
15
|
+
# Public metric name.
|
16
|
+
attr_accessor :name
|
17
|
+
|
18
|
+
# Whether the experiment should record the effects of this filter.
|
19
|
+
attr_accessor :track_effects
|
20
|
+
|
21
|
+
# If true, keep items that match the filter; if false, exclude them.
|
22
|
+
attr_accessor :includes
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:domain => :domain,
|
28
|
+
:name => :name,
|
29
|
+
:track_effects => :trackEffects,
|
30
|
+
:includes => :includes
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Attribute type mapping.
|
35
|
+
def self.types_mapping
|
36
|
+
{
|
37
|
+
:domain => :"String",
|
38
|
+
:name => :"String",
|
39
|
+
:track_effects => :"Boolean",
|
40
|
+
:includes => :"Boolean"
|
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::MetricsFilter` 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::MetricsFilter`. 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?(:domain)
|
75
|
+
self.domain = attributes[:domain]
|
76
|
+
else
|
77
|
+
self.domain = nil
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:name)
|
81
|
+
self.name = attributes[:name]
|
82
|
+
else
|
83
|
+
self.name = nil
|
84
|
+
end
|
85
|
+
|
86
|
+
if attributes.key?(:track_effects)
|
87
|
+
self.track_effects = attributes[:track_effects]
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:includes)
|
91
|
+
self.includes = attributes[:includes]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Checks equality by comparing each attribute.
|
96
|
+
# @param [Object] Object to be compared
|
97
|
+
def ==(other)
|
98
|
+
return true if self.equal?(other)
|
99
|
+
self.class == other.class &&
|
100
|
+
domain == other.domain &&
|
101
|
+
name == other.name &&
|
102
|
+
track_effects == other.track_effects &&
|
103
|
+
includes == other.includes
|
104
|
+
end
|
105
|
+
|
106
|
+
# @see the `==` method
|
107
|
+
# @param [Object] Object to be compared
|
108
|
+
def eql?(other)
|
109
|
+
self == other
|
110
|
+
end
|
111
|
+
|
112
|
+
# Calculates hash code according to all attributes.
|
113
|
+
# @return [Integer] Hash code
|
114
|
+
def hash
|
115
|
+
[domain, name, track_effects, includes].hash
|
116
|
+
end
|
117
|
+
|
118
|
+
# Builds the object from hash
|
119
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
120
|
+
# @return [Object] Returns the model itself
|
121
|
+
def self.build_from_hash(attributes)
|
122
|
+
return nil unless attributes.is_a?(Hash)
|
123
|
+
attributes = attributes.transform_keys(&:to_sym)
|
124
|
+
transformed_hash = {}
|
125
|
+
types_mapping.each_pair do |key, type|
|
126
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
127
|
+
transformed_hash[key.to_sym] = nil
|
128
|
+
elsif type =~ /\AArray<(.*)>/i
|
129
|
+
# check to ensure the input is an array given that the attribute
|
130
|
+
# is documented as an array but the input is not
|
131
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
132
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
133
|
+
_deserialize(::Regexp.last_match(1), v)
|
134
|
+
}
|
135
|
+
end
|
136
|
+
elsif !attributes[attribute_map[key]].nil?
|
137
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
new(transformed_hash)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Deserializes the data based on type
|
145
|
+
# @param string type Data type
|
146
|
+
# @param string value Value to be deserialized
|
147
|
+
# @return [Object] Deserialized data
|
148
|
+
def self._deserialize(type, value)
|
149
|
+
case type.to_sym
|
150
|
+
when :Time
|
151
|
+
Time.parse(value)
|
152
|
+
when :Date
|
153
|
+
Date.parse(value)
|
154
|
+
when :String
|
155
|
+
value.to_s
|
156
|
+
when :Integer
|
157
|
+
value.to_i
|
158
|
+
when :Float
|
159
|
+
value.to_f
|
160
|
+
when :Boolean
|
161
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
162
|
+
true
|
163
|
+
else
|
164
|
+
false
|
165
|
+
end
|
166
|
+
|
167
|
+
when :Object
|
168
|
+
# generic object (usually a Hash), return directly
|
169
|
+
value
|
170
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
171
|
+
inner_type = Regexp.last_match[:inner_type]
|
172
|
+
value.map { |v| _deserialize(inner_type, v) }
|
173
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
174
|
+
k_type = Regexp.last_match[:k_type]
|
175
|
+
v_type = Regexp.last_match[:v_type]
|
176
|
+
{}.tap do |hash|
|
177
|
+
value.each do |k, v|
|
178
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
# model
|
182
|
+
else
|
183
|
+
# models (e.g. Pet) or oneOf
|
184
|
+
klass = Algolia::AbtestingV3.const_get(type)
|
185
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
186
|
+
.build_from_hash(value)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
# Returns the string representation of the object
|
191
|
+
# @return [String] String presentation of the object
|
192
|
+
def to_s
|
193
|
+
to_hash.to_s
|
194
|
+
end
|
195
|
+
|
196
|
+
# to_body is an alias to to_hash (backward compatibility)
|
197
|
+
# @return [Hash] Returns the object in the form of hash
|
198
|
+
def to_body
|
199
|
+
to_hash
|
200
|
+
end
|
201
|
+
|
202
|
+
def to_json(*_args)
|
203
|
+
to_hash.to_json
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the object in the form of hash
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_hash
|
209
|
+
hash = {}
|
210
|
+
self.class.attribute_map.each_pair do |attr, param|
|
211
|
+
value = send(attr)
|
212
|
+
if value.nil?
|
213
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
214
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
215
|
+
end
|
216
|
+
|
217
|
+
hash[param] = _to_hash(value)
|
218
|
+
end
|
219
|
+
|
220
|
+
hash
|
221
|
+
end
|
222
|
+
|
223
|
+
# Outputs non-array value in the form of hash
|
224
|
+
# For object, use to_hash. Otherwise, just return the value
|
225
|
+
# @param [Object] value Any valid value
|
226
|
+
# @return [Hash] Returns the value in the form of hash
|
227
|
+
def _to_hash(value)
|
228
|
+
if value.is_a?(Array)
|
229
|
+
value.compact.map { |v| _to_hash(v) }
|
230
|
+
elsif value.is_a?(Hash)
|
231
|
+
{}.tap do |hash|
|
232
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
233
|
+
end
|
234
|
+
elsif value.respond_to?(:to_hash)
|
235
|
+
value.to_hash
|
236
|
+
else
|
237
|
+
value
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
end
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|