algolia 3.39.1 → 3.40.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 (31) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/release.yml +1 -1
  3. data/CHANGELOG.md +14 -0
  4. data/Gemfile.lock +1 -1
  5. data/lib/algolia/api/ingestion_client.rb +71 -0
  6. data/lib/algolia/api/search_client.rb +342 -22
  7. data/lib/algolia/chunked_helper_options.rb +15 -0
  8. data/lib/algolia/configuration.rb +3 -1
  9. data/lib/algolia/models/abtesting/ab_test.rb +5 -0
  10. data/lib/algolia/models/query-suggestions/configuration.rb +1 -0
  11. data/lib/algolia/models/query-suggestions/configuration_response.rb +1 -0
  12. data/lib/algolia/models/query-suggestions/configuration_with_index.rb +1 -0
  13. data/lib/algolia/models/query-suggestions/source_index.rb +4 -0
  14. data/lib/algolia/models/recommend/fallback_params.rb +2 -1
  15. data/lib/algolia/models/recommend/recommend_search_params.rb +2 -1
  16. data/lib/algolia/models/search/browse_params_object.rb +2 -1
  17. data/lib/algolia/models/search/consequence_params.rb +2 -1
  18. data/lib/algolia/models/search/fetched_index.rb +25 -4
  19. data/lib/algolia/models/search/fetched_index_ab_test.rb +253 -0
  20. data/lib/algolia/models/search/fetched_index_ab_test_target.rb +210 -0
  21. data/lib/algolia/models/search/fetched_index_ab_test_variant.rb +242 -0
  22. data/lib/algolia/models/search/index_settings.rb +2 -1
  23. data/lib/algolia/models/search/search_for_facets.rb +2 -1
  24. data/lib/algolia/models/search/search_for_hits.rb +2 -1
  25. data/lib/algolia/models/search/search_params_object.rb +2 -1
  26. data/lib/algolia/models/search/search_response_partial.rb +587 -0
  27. data/lib/algolia/models/search/search_result.rb +2 -1
  28. data/lib/algolia/models/search/settings_response.rb +2 -1
  29. data/lib/algolia/version.rb +1 -1
  30. data/lib/algolia.rb +1 -2
  31. metadata +7 -2
@@ -0,0 +1,242 @@
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 Search
10
+ # A/B test variant for an index.
11
+ class FetchedIndexAbTestVariant
12
+ # Index name of the variant. Only present for v0/v1 tests; in v2 this moves into `payload`.
13
+ attr_accessor :index_name
14
+
15
+ # Percentage of search traffic routed to this variant.
16
+ attr_accessor :percentage
17
+
18
+ # URL-encoded custom search parameters applied to this variant. Only present for v0/v1 tests; in v2 this moves into `payload`.
19
+ attr_accessor :custom_search_parameters
20
+
21
+ # Type-specific configuration. Only present for v2 and later tests. Shape depends on the parent A/B test's `type`.
22
+ attr_accessor :payload
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :index_name => :indexName,
28
+ :percentage => :percentage,
29
+ :custom_search_parameters => :customSearchParameters,
30
+ :payload => :payload
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.types_mapping
36
+ {
37
+ :index_name => :"String",
38
+ :percentage => :"Integer",
39
+ :custom_search_parameters => :"String",
40
+ :payload => :"Hash<String, Object>"
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::FetchedIndexAbTestVariant` 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::FetchedIndexAbTestVariant`. 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?(:index_name)
75
+ self.index_name = attributes[:index_name]
76
+ end
77
+
78
+ if attributes.key?(:percentage)
79
+ self.percentage = attributes[:percentage]
80
+ else
81
+ self.percentage = nil
82
+ end
83
+
84
+ if attributes.key?(:custom_search_parameters)
85
+ self.custom_search_parameters = attributes[:custom_search_parameters]
86
+ end
87
+
88
+ if attributes.key?(:payload)
89
+ if (value = attributes[:payload]).is_a?(Hash)
90
+ self.payload = value
91
+ end
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
+ index_name == other.index_name &&
101
+ percentage == other.percentage &&
102
+ custom_search_parameters == other.custom_search_parameters &&
103
+ payload == other.payload
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
+ [index_name, percentage, custom_search_parameters, payload].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::Search.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
+ end
241
+ end
242
+ end
@@ -319,7 +319,8 @@ module Algolia
319
319
  Set.new(
320
320
  [
321
321
  :user_data,
322
- :optional_words
322
+ :optional_words,
323
+ :re_ranking_apply_filter
323
324
  ]
324
325
  )
325
326
  end
@@ -408,7 +408,8 @@ module Algolia
408
408
  Set.new(
409
409
  [
410
410
  :inside_bounding_box,
411
- :optional_words
411
+ :optional_words,
412
+ :re_ranking_apply_filter
412
413
  ]
413
414
  )
414
415
  end
@@ -389,7 +389,8 @@ module Algolia
389
389
  Set.new(
390
390
  [
391
391
  :inside_bounding_box,
392
- :optional_words
392
+ :optional_words,
393
+ :re_ranking_apply_filter
393
394
  ]
394
395
  )
395
396
  end
@@ -372,7 +372,8 @@ module Algolia
372
372
  Set.new(
373
373
  [
374
374
  :inside_bounding_box,
375
- :optional_words
375
+ :optional_words,
376
+ :re_ranking_apply_filter
376
377
  ]
377
378
  )
378
379
  end