algolia 3.30.0 → 3.32.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.
@@ -1,270 +0,0 @@
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 ScheduleABTestsRequest
11
- # A/B test name.
12
- attr_accessor :name
13
-
14
- # A/B test variants.
15
- attr_accessor :variants
16
-
17
- # A/B test metrics involved in the test. Only these metrics will be considered when calculating results.
18
- attr_accessor :metrics
19
-
20
- attr_accessor :configuration
21
-
22
- # Date and time when the A/B test is scheduled to start, in RFC 3339 format.
23
- attr_accessor :scheduled_at
24
-
25
- # End date and time of the A/B test, in RFC 3339 format.
26
- attr_accessor :end_at
27
-
28
- # Attribute mapping from ruby-style variable name to JSON key.
29
- def self.attribute_map
30
- {
31
- :name => :name,
32
- :variants => :variants,
33
- :metrics => :metrics,
34
- :configuration => :configuration,
35
- :scheduled_at => :scheduledAt,
36
- :end_at => :endAt
37
- }
38
- end
39
-
40
- # Attribute type mapping.
41
- def self.types_mapping
42
- {
43
- :name => :"String",
44
- :variants => :"Array<AddABTestsVariant>",
45
- :metrics => :"Array<CreateMetric>",
46
- :configuration => :"ABTestConfiguration",
47
- :scheduled_at => :"String",
48
- :end_at => :"String"
49
- }
50
- end
51
-
52
- # List of attributes with nullable: true
53
- def self.openapi_nullable
54
- Set.new(
55
- []
56
- )
57
- end
58
-
59
- # Initializes the object
60
- # @param [Hash] attributes Model attributes in the form of hash
61
- def initialize(attributes = {})
62
- if (!attributes.is_a?(Hash))
63
- raise(
64
- ArgumentError,
65
- "The input argument (attributes) must be a hash in `Algolia::ScheduleABTestsRequest` initialize method"
66
- )
67
- end
68
-
69
- # check to see if the attribute exists and convert string to symbol for hash key
70
- attributes = attributes.each_with_object({}) { |(k, v), h|
71
- if (!self.class.attribute_map.key?(k.to_sym))
72
- raise(
73
- ArgumentError,
74
- "`#{k}` is not a valid attribute in `Algolia::ScheduleABTestsRequest`. Please check the name to make sure it's valid. List of attributes: " +
75
- self.class.attribute_map.keys.inspect
76
- )
77
- end
78
-
79
- h[k.to_sym] = v
80
- }
81
-
82
- if attributes.key?(:name)
83
- self.name = attributes[:name]
84
- else
85
- self.name = nil
86
- end
87
-
88
- if attributes.key?(:variants)
89
- if (value = attributes[:variants]).is_a?(Array)
90
- self.variants = value
91
- end
92
- else
93
- self.variants = nil
94
- end
95
-
96
- if attributes.key?(:metrics)
97
- if (value = attributes[:metrics]).is_a?(Array)
98
- self.metrics = value
99
- end
100
- else
101
- self.metrics = nil
102
- end
103
-
104
- if attributes.key?(:configuration)
105
- self.configuration = attributes[:configuration]
106
- end
107
-
108
- if attributes.key?(:scheduled_at)
109
- self.scheduled_at = attributes[:scheduled_at]
110
- else
111
- self.scheduled_at = nil
112
- end
113
-
114
- if attributes.key?(:end_at)
115
- self.end_at = attributes[:end_at]
116
- else
117
- self.end_at = nil
118
- end
119
- end
120
-
121
- # Checks equality by comparing each attribute.
122
- # @param [Object] Object to be compared
123
- def ==(other)
124
- return true if self.equal?(other)
125
- self.class == other.class &&
126
- name == other.name &&
127
- variants == other.variants &&
128
- metrics == other.metrics &&
129
- configuration == other.configuration &&
130
- scheduled_at == other.scheduled_at &&
131
- end_at == other.end_at
132
- end
133
-
134
- # @see the `==` method
135
- # @param [Object] Object to be compared
136
- def eql?(other)
137
- self == other
138
- end
139
-
140
- # Calculates hash code according to all attributes.
141
- # @return [Integer] Hash code
142
- def hash
143
- [name, variants, metrics, configuration, scheduled_at, end_at].hash
144
- end
145
-
146
- # Builds the object from hash
147
- # @param [Hash] attributes Model attributes in the form of hash
148
- # @return [Object] Returns the model itself
149
- def self.build_from_hash(attributes)
150
- return nil unless attributes.is_a?(Hash)
151
- attributes = attributes.transform_keys(&:to_sym)
152
- transformed_hash = {}
153
- types_mapping.each_pair do |key, type|
154
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
155
- transformed_hash[key.to_sym] = nil
156
- elsif type =~ /\AArray<(.*)>/i
157
- # check to ensure the input is an array given that the attribute
158
- # is documented as an array but the input is not
159
- if attributes[attribute_map[key]].is_a?(Array)
160
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
161
- _deserialize(::Regexp.last_match(1), v)
162
- }
163
- end
164
- elsif !attributes[attribute_map[key]].nil?
165
- transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
166
- end
167
- end
168
-
169
- new(transformed_hash)
170
- end
171
-
172
- # Deserializes the data based on type
173
- # @param string type Data type
174
- # @param string value Value to be deserialized
175
- # @return [Object] Deserialized data
176
- def self._deserialize(type, value)
177
- case type.to_sym
178
- when :Time
179
- Time.parse(value)
180
- when :Date
181
- Date.parse(value)
182
- when :String
183
- value.to_s
184
- when :Integer
185
- value.to_i
186
- when :Float
187
- value.to_f
188
- when :Boolean
189
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
190
- true
191
- else
192
- false
193
- end
194
-
195
- when :Object
196
- # generic object (usually a Hash), return directly
197
- value
198
- when /\AArray<(?<inner_type>.+)>\z/
199
- inner_type = Regexp.last_match[:inner_type]
200
- value.map { |v| _deserialize(inner_type, v) }
201
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
202
- k_type = Regexp.last_match[:k_type]
203
- v_type = Regexp.last_match[:v_type]
204
- {}.tap do |hash|
205
- value.each do |k, v|
206
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
207
- end
208
- end
209
- # model
210
- else
211
- # models (e.g. Pet) or oneOf
212
- klass = Algolia::AbtestingV3.const_get(type)
213
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
214
- .build_from_hash(value)
215
- end
216
- end
217
-
218
- # Returns the string representation of the object
219
- # @return [String] String presentation of the object
220
- def to_s
221
- to_hash.to_s
222
- end
223
-
224
- # to_body is an alias to to_hash (backward compatibility)
225
- # @return [Hash] Returns the object in the form of hash
226
- def to_body
227
- to_hash
228
- end
229
-
230
- def to_json(*_args)
231
- to_hash.to_json
232
- end
233
-
234
- # Returns the object in the form of hash
235
- # @return [Hash] Returns the object in the form of hash
236
- def to_hash
237
- hash = {}
238
- self.class.attribute_map.each_pair do |attr, param|
239
- value = send(attr)
240
- if value.nil?
241
- is_nullable = self.class.openapi_nullable.include?(attr)
242
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
243
- end
244
-
245
- hash[param] = _to_hash(value)
246
- end
247
-
248
- hash
249
- end
250
-
251
- # Outputs non-array value in the form of hash
252
- # For object, use to_hash. Otherwise, just return the value
253
- # @param [Object] value Any valid value
254
- # @return [Hash] Returns the value in the form of hash
255
- def _to_hash(value)
256
- if value.is_a?(Array)
257
- value.compact.map { |v| _to_hash(v) }
258
- elsif value.is_a?(Hash)
259
- {}.tap do |hash|
260
- value.each { |k, v| hash[k] = _to_hash(v) }
261
- end
262
- elsif value.respond_to?(:to_hash)
263
- value.to_hash
264
- else
265
- value
266
- end
267
- end
268
- end
269
- end
270
- end