algolia 3.37.1 → 3.39.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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +15 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/algolia/api/monitoring_client.rb +2 -2
  5. data/lib/algolia/api/search_client.rb +4 -4
  6. data/lib/algolia/models/composition/external_injected_item.rb +1 -0
  7. data/lib/algolia/models/composition/external_injection.rb +1 -1
  8. data/lib/algolia/models/composition/{external.rb → injected_item_external.rb} +6 -3
  9. data/lib/algolia/models/composition/{external_source.rb → injected_item_external_source.rb} +4 -4
  10. data/lib/algolia/models/composition/injected_item_recommend_source.rb +216 -0
  11. data/lib/algolia/models/composition/{search.rb → injected_item_search.rb} +6 -3
  12. data/lib/algolia/models/composition/{search_source.rb → injected_item_search_source.rb} +4 -4
  13. data/lib/algolia/models/composition/injected_item_source.rb +3 -2
  14. data/lib/algolia/models/composition/injection.rb +2 -2
  15. data/lib/algolia/models/composition/{injected_item.rb → injection_injected_item.rb} +3 -3
  16. data/lib/algolia/models/composition/{main.rb → injection_main.rb} +8 -6
  17. data/lib/algolia/models/composition/injection_main_recommend_source.rb +216 -0
  18. data/lib/algolia/models/composition/{composition_source.rb → injection_main_search_source.rb} +12 -4
  19. data/lib/algolia/models/composition/injection_main_source.rb +109 -0
  20. data/lib/algolia/models/composition/main_recommend.rb +250 -0
  21. data/lib/algolia/models/composition/{composition_source_search.rb → main_search.rb} +4 -4
  22. data/lib/algolia/models/composition/model.rb +33 -0
  23. data/lib/algolia/models/composition/params.rb +1 -1
  24. data/lib/algolia/models/composition/recommend.rb +250 -0
  25. data/lib/algolia/models/composition/request_body.rb +16 -4
  26. data/lib/algolia/models/ingestion/source_algolia_index.rb +227 -0
  27. data/lib/algolia/models/ingestion/source_input.rb +1 -0
  28. data/lib/algolia/models/ingestion/source_type.rb +13 -1
  29. data/lib/algolia/models/ingestion/source_update_algolia_index.rb +218 -0
  30. data/lib/algolia/models/ingestion/source_update_input.rb +1 -0
  31. data/lib/algolia/models/search/auto_filtering_filter_entry.rb +108 -0
  32. data/lib/algolia/models/search/auto_filtering_result.rb +242 -0
  33. data/lib/algolia/models/search/browse_response.rb +10 -0
  34. data/lib/algolia/models/search/category_prediction.rb +218 -0
  35. data/lib/algolia/models/search/category_prediction_bin.rb +37 -0
  36. data/lib/algolia/models/search/hierarchy_path_entry.rb +227 -0
  37. data/lib/algolia/models/search/query_categorization.rb +248 -0
  38. data/lib/algolia/models/search/query_categorization_type.rb +36 -0
  39. data/lib/algolia/models/search/response_extensions.rb +207 -0
  40. data/lib/algolia/models/search/search_extensions.rb +207 -0
  41. data/lib/algolia/models/search/search_extensions_query_categorization.rb +218 -0
  42. data/lib/algolia/models/search/search_for_hits.rb +14 -4
  43. data/lib/algolia/models/search/search_response.rb +14 -4
  44. data/lib/algolia/version.rb +1 -1
  45. metadata +27 -9
@@ -0,0 +1,250 @@
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 Composition
10
+ class Recommend
11
+ # Index to retrieve recommendations from.
12
+ attr_accessor :index_name
13
+
14
+ attr_accessor :model
15
+
16
+ # Minimum score a recommendation must have to be included.
17
+ attr_accessor :threshold
18
+
19
+ attr_accessor :query_parameters
20
+
21
+ attr_accessor :fallback_parameters
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :index_name => :indexName,
27
+ :model => :model,
28
+ :threshold => :threshold,
29
+ :query_parameters => :queryParameters,
30
+ :fallback_parameters => :fallbackParameters
31
+ }
32
+ end
33
+
34
+ # Attribute type mapping.
35
+ def self.types_mapping
36
+ {
37
+ :index_name => :"String",
38
+ :model => :"Model",
39
+ :threshold => :"Integer",
40
+ :query_parameters => :"BaseInjectionQueryParameters",
41
+ :fallback_parameters => :"BaseInjectionQueryParameters"
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new(
48
+ []
49
+ )
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ raise(
57
+ ArgumentError,
58
+ "The input argument (attributes) must be a hash in `Algolia::Recommend` initialize method"
59
+ )
60
+ end
61
+
62
+ # check to see if the attribute exists and convert string to symbol for hash key
63
+ attributes = attributes.each_with_object({}) { |(k, v), h|
64
+ if (!self.class.attribute_map.key?(k.to_sym))
65
+ raise(
66
+ ArgumentError,
67
+ "`#{k}` is not a valid attribute in `Algolia::Recommend`. Please check the name to make sure it's valid. List of attributes: " +
68
+ self.class.attribute_map.keys.inspect
69
+ )
70
+ end
71
+
72
+ h[k.to_sym] = v
73
+ }
74
+
75
+ if attributes.key?(:index_name)
76
+ self.index_name = attributes[:index_name]
77
+ else
78
+ self.index_name = nil
79
+ end
80
+
81
+ if attributes.key?(:model)
82
+ self.model = attributes[:model]
83
+ else
84
+ self.model = nil
85
+ end
86
+
87
+ if attributes.key?(:threshold)
88
+ self.threshold = attributes[:threshold]
89
+ else
90
+ self.threshold = nil
91
+ end
92
+
93
+ if attributes.key?(:query_parameters)
94
+ self.query_parameters = attributes[:query_parameters]
95
+ end
96
+
97
+ if attributes.key?(:fallback_parameters)
98
+ self.fallback_parameters = attributes[:fallback_parameters]
99
+ end
100
+ end
101
+
102
+ # Checks equality by comparing each attribute.
103
+ # @param [Object] Object to be compared
104
+ def ==(other)
105
+ return true if self.equal?(other)
106
+ self.class == other.class &&
107
+ index_name == other.index_name &&
108
+ model == other.model &&
109
+ threshold == other.threshold &&
110
+ query_parameters == other.query_parameters &&
111
+ fallback_parameters == other.fallback_parameters
112
+ end
113
+
114
+ # @see the `==` method
115
+ # @param [Object] Object to be compared
116
+ def eql?(other)
117
+ self == other
118
+ end
119
+
120
+ # Calculates hash code according to all attributes.
121
+ # @return [Integer] Hash code
122
+ def hash
123
+ [index_name, model, threshold, query_parameters, fallback_parameters].hash
124
+ end
125
+
126
+ # Builds the object from hash
127
+ # @param [Hash] attributes Model attributes in the form of hash
128
+ # @return [Object] Returns the model itself
129
+ def self.build_from_hash(attributes)
130
+ return nil unless attributes.is_a?(Hash)
131
+ attributes = attributes.transform_keys(&:to_sym)
132
+ transformed_hash = {}
133
+ types_mapping.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash[key.to_sym] = nil
136
+ elsif type =~ /\AArray<(.*)>/i
137
+ # check to ensure the input is an array given that the attribute
138
+ # is documented as an array but the input is not
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
141
+ _deserialize(::Regexp.last_match(1), v)
142
+ }
143
+ end
144
+ elsif !attributes[attribute_map[key]].nil?
145
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
146
+ end
147
+ end
148
+
149
+ new(transformed_hash)
150
+ end
151
+
152
+ # Deserializes the data based on type
153
+ # @param string type Data type
154
+ # @param string value Value to be deserialized
155
+ # @return [Object] Deserialized data
156
+ def self._deserialize(type, value)
157
+ case type.to_sym
158
+ when :Time
159
+ Time.parse(value)
160
+ when :Date
161
+ Date.parse(value)
162
+ when :String
163
+ value.to_s
164
+ when :Integer
165
+ value.to_i
166
+ when :Float
167
+ value.to_f
168
+ when :Boolean
169
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
170
+ true
171
+ else
172
+ false
173
+ end
174
+
175
+ when :Object
176
+ # generic object (usually a Hash), return directly
177
+ value
178
+ when /\AArray<(?<inner_type>.+)>\z/
179
+ inner_type = Regexp.last_match[:inner_type]
180
+ value.map { |v| _deserialize(inner_type, v) }
181
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
182
+ k_type = Regexp.last_match[:k_type]
183
+ v_type = Regexp.last_match[:v_type]
184
+ {}.tap do |hash|
185
+ value.each do |k, v|
186
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
187
+ end
188
+ end
189
+ # model
190
+ else
191
+ # models (e.g. Pet) or oneOf
192
+ klass = Algolia::Composition.const_get(type)
193
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
194
+ .build_from_hash(value)
195
+ end
196
+ end
197
+
198
+ # Returns the string representation of the object
199
+ # @return [String] String presentation of the object
200
+ def to_s
201
+ to_hash.to_s
202
+ end
203
+
204
+ # to_body is an alias to to_hash (backward compatibility)
205
+ # @return [Hash] Returns the object in the form of hash
206
+ def to_body
207
+ to_hash
208
+ end
209
+
210
+ def to_json(*_args)
211
+ to_hash.to_json
212
+ end
213
+
214
+ # Returns the object in the form of hash
215
+ # @return [Hash] Returns the object in the form of hash
216
+ def to_hash
217
+ hash = {}
218
+ self.class.attribute_map.each_pair do |attr, param|
219
+ value = send(attr)
220
+ if value.nil?
221
+ is_nullable = self.class.openapi_nullable.include?(attr)
222
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
223
+ end
224
+
225
+ hash[param] = _to_hash(value)
226
+ end
227
+
228
+ hash
229
+ end
230
+
231
+ # Outputs non-array value in the form of hash
232
+ # For object, use to_hash. Otherwise, just return the value
233
+ # @param [Object] value Any valid value
234
+ # @return [Hash] Returns the value in the form of hash
235
+ def _to_hash(value)
236
+ if value.is_a?(Array)
237
+ value.compact.map { |v| _to_hash(v) }
238
+ elsif value.is_a?(Hash)
239
+ {}.tap do |hash|
240
+ value.each { |k, v| hash[k] = _to_hash(v) }
241
+ end
242
+ elsif value.respond_to?(:to_hash)
243
+ value.to_hash
244
+ else
245
+ value
246
+ end
247
+ end
248
+ end
249
+ end
250
+ end
@@ -10,17 +10,22 @@ module Algolia
10
10
  class RequestBody
11
11
  attr_accessor :params
12
12
 
13
+ # A list of Feed IDs that specifies the order in which to order the results in the response. The IDs should be a subset of those in the `feeds` object of the targeted `multifeed` Composition / Composition Rule, and only those specified will be processed. The value overrides the value in the defined behavior, and when unspecified, the value defined in the behavior is used. When neither value is present, all feeds are processed.
14
+ attr_accessor :feeds_order
15
+
13
16
  # Attribute mapping from ruby-style variable name to JSON key.
14
17
  def self.attribute_map
15
18
  {
16
- :params => :params
19
+ :params => :params,
20
+ :feeds_order => :feedsOrder
17
21
  }
18
22
  end
19
23
 
20
24
  # Attribute type mapping.
21
25
  def self.types_mapping
22
26
  {
23
- :params => :"Params"
27
+ :params => :"Params",
28
+ :feeds_order => :"Array<String>"
24
29
  }
25
30
  end
26
31
 
@@ -57,6 +62,12 @@ module Algolia
57
62
  if attributes.key?(:params)
58
63
  self.params = attributes[:params]
59
64
  end
65
+
66
+ if attributes.key?(:feeds_order)
67
+ if (value = attributes[:feeds_order]).is_a?(Array)
68
+ self.feeds_order = value
69
+ end
70
+ end
60
71
  end
61
72
 
62
73
  # Checks equality by comparing each attribute.
@@ -64,7 +75,8 @@ module Algolia
64
75
  def ==(other)
65
76
  return true if self.equal?(other)
66
77
  self.class == other.class &&
67
- params == other.params
78
+ params == other.params &&
79
+ feeds_order == other.feeds_order
68
80
  end
69
81
 
70
82
  # @see the `==` method
@@ -76,7 +88,7 @@ module Algolia
76
88
  # Calculates hash code according to all attributes.
77
89
  # @return [Integer] Hash code
78
90
  def hash
79
- [params].hash
91
+ [params, feeds_order].hash
80
92
  end
81
93
 
82
94
  # Builds the object from hash
@@ -0,0 +1,227 @@
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 Ingestion
10
+ # Specific configuration attributes of an `algoliaIndex` source.
11
+ class SourceAlgoliaIndex
12
+ # Name of the Algolia index to read records from.
13
+ attr_accessor :index_name
14
+
15
+ # SQL-like filter expression applied while browsing the source index. See [filters](https://www.algolia.com/doc/api-reference/api-parameters/filters/).
16
+ attr_accessor :filters
17
+
18
+ # Attribute mapping from ruby-style variable name to JSON key.
19
+ def self.attribute_map
20
+ {
21
+ :index_name => :indexName,
22
+ :filters => :filters
23
+ }
24
+ end
25
+
26
+ # Returns the keys that uniquely identify this oneOf variant when present
27
+ def self.discriminator_attributes
28
+ [
29
+ :indexName
30
+ ]
31
+ end
32
+
33
+ # Attribute type mapping.
34
+ def self.types_mapping
35
+ {
36
+ :index_name => :"String",
37
+ :filters => :"String"
38
+ }
39
+ end
40
+
41
+ # List of attributes with nullable: true
42
+ def self.openapi_nullable
43
+ Set.new(
44
+ []
45
+ )
46
+ end
47
+
48
+ # Initializes the object
49
+ # @param [Hash] attributes Model attributes in the form of hash
50
+ def initialize(attributes = {})
51
+ if (!attributes.is_a?(Hash))
52
+ raise(
53
+ ArgumentError,
54
+ "The input argument (attributes) must be a hash in `Algolia::SourceAlgoliaIndex` initialize method"
55
+ )
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ attributes = attributes.each_with_object({}) { |(k, v), h|
60
+ if (!self.class.attribute_map.key?(k.to_sym))
61
+ raise(
62
+ ArgumentError,
63
+ "`#{k}` is not a valid attribute in `Algolia::SourceAlgoliaIndex`. Please check the name to make sure it's valid. List of attributes: " +
64
+ self.class.attribute_map.keys.inspect
65
+ )
66
+ end
67
+
68
+ h[k.to_sym] = v
69
+ }
70
+
71
+ if attributes.key?(:index_name)
72
+ self.index_name = attributes[:index_name]
73
+ else
74
+ self.index_name = nil
75
+ end
76
+
77
+ if attributes.key?(:filters)
78
+ self.filters = attributes[:filters]
79
+ end
80
+ end
81
+
82
+ # Checks equality by comparing each attribute.
83
+ # @param [Object] Object to be compared
84
+ def ==(other)
85
+ return true if self.equal?(other)
86
+ self.class == other.class &&
87
+ index_name == other.index_name &&
88
+ filters == other.filters
89
+ end
90
+
91
+ # @see the `==` method
92
+ # @param [Object] Object to be compared
93
+ def eql?(other)
94
+ self == other
95
+ end
96
+
97
+ # Calculates hash code according to all attributes.
98
+ # @return [Integer] Hash code
99
+ def hash
100
+ [index_name, filters].hash
101
+ end
102
+
103
+ # Builds the object from hash
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ # @return [Object] Returns the model itself
106
+ def self.build_from_hash(attributes)
107
+ return nil unless attributes.is_a?(Hash)
108
+ attributes = attributes.transform_keys(&:to_sym)
109
+ transformed_hash = {}
110
+ types_mapping.each_pair do |key, type|
111
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
112
+ transformed_hash[key.to_sym] = nil
113
+ elsif type =~ /\AArray<(.*)>/i
114
+ # check to ensure the input is an array given that the attribute
115
+ # is documented as an array but the input is not
116
+ if attributes[attribute_map[key]].is_a?(Array)
117
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
118
+ _deserialize(::Regexp.last_match(1), v)
119
+ }
120
+ end
121
+ elsif !attributes[attribute_map[key]].nil?
122
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
123
+ end
124
+ end
125
+
126
+ new(transformed_hash)
127
+ end
128
+
129
+ # Deserializes the data based on type
130
+ # @param string type Data type
131
+ # @param string value Value to be deserialized
132
+ # @return [Object] Deserialized data
133
+ def self._deserialize(type, value)
134
+ case type.to_sym
135
+ when :Time
136
+ Time.parse(value)
137
+ when :Date
138
+ Date.parse(value)
139
+ when :String
140
+ value.to_s
141
+ when :Integer
142
+ value.to_i
143
+ when :Float
144
+ value.to_f
145
+ when :Boolean
146
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
147
+ true
148
+ else
149
+ false
150
+ end
151
+
152
+ when :Object
153
+ # generic object (usually a Hash), return directly
154
+ value
155
+ when /\AArray<(?<inner_type>.+)>\z/
156
+ inner_type = Regexp.last_match[:inner_type]
157
+ value.map { |v| _deserialize(inner_type, v) }
158
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
159
+ k_type = Regexp.last_match[:k_type]
160
+ v_type = Regexp.last_match[:v_type]
161
+ {}.tap do |hash|
162
+ value.each do |k, v|
163
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
164
+ end
165
+ end
166
+ # model
167
+ else
168
+ # models (e.g. Pet) or oneOf
169
+ klass = Algolia::Ingestion.const_get(type)
170
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
171
+ .build_from_hash(value)
172
+ end
173
+ end
174
+
175
+ # Returns the string representation of the object
176
+ # @return [String] String presentation of the object
177
+ def to_s
178
+ to_hash.to_s
179
+ end
180
+
181
+ # to_body is an alias to to_hash (backward compatibility)
182
+ # @return [Hash] Returns the object in the form of hash
183
+ def to_body
184
+ to_hash
185
+ end
186
+
187
+ def to_json(*_args)
188
+ to_hash.to_json
189
+ end
190
+
191
+ # Returns the object in the form of hash
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_hash
194
+ hash = {}
195
+ self.class.attribute_map.each_pair do |attr, param|
196
+ value = send(attr)
197
+ if value.nil?
198
+ is_nullable = self.class.openapi_nullable.include?(attr)
199
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
200
+ end
201
+
202
+ hash[param] = _to_hash(value)
203
+ end
204
+
205
+ hash
206
+ end
207
+
208
+ # Outputs non-array value in the form of hash
209
+ # For object, use to_hash. Otherwise, just return the value
210
+ # @param [Object] value Any valid value
211
+ # @return [Hash] Returns the value in the form of hash
212
+ def _to_hash(value)
213
+ if value.is_a?(Array)
214
+ value.compact.map { |v| _to_hash(v) }
215
+ elsif value.is_a?(Hash)
216
+ {}.tap do |hash|
217
+ value.each { |k, v| hash[k] = _to_hash(v) }
218
+ end
219
+ elsif value.respond_to?(:to_hash)
220
+ value.to_hash
221
+ else
222
+ value
223
+ end
224
+ end
225
+ end
226
+ end
227
+ end
@@ -12,6 +12,7 @@ module Algolia
12
12
  # List of class defined in oneOf (OpenAPI v3)
13
13
  def openapi_one_of
14
14
  [
15
+ :"SourceAlgoliaIndex",
15
16
  :"SourceBigCommerce",
16
17
  :"SourceBigQuery",
17
18
  :"SourceCSV",
@@ -8,6 +8,7 @@ require "time"
8
8
  module Algolia
9
9
  module Ingestion
10
10
  class SourceType
11
+ ALGOLIA_INDEX = "algoliaIndex".freeze
11
12
  BIGCOMMERCE = "bigcommerce".freeze
12
13
  BIGQUERY = "bigquery".freeze
13
14
  COMMERCETOOLS = "commercetools".freeze
@@ -19,7 +20,18 @@ module Algolia
19
20
  PUSH = "push".freeze
20
21
 
21
22
  def self.all_vars
22
- @all_vars ||= [BIGCOMMERCE, BIGQUERY, COMMERCETOOLS, CSV, DOCKER, GA4_BIGQUERY_EXPORT, JSON, SHOPIFY, PUSH].freeze
23
+ @all_vars ||= [
24
+ ALGOLIA_INDEX,
25
+ BIGCOMMERCE,
26
+ BIGQUERY,
27
+ COMMERCETOOLS,
28
+ CSV,
29
+ DOCKER,
30
+ GA4_BIGQUERY_EXPORT,
31
+ JSON,
32
+ SHOPIFY,
33
+ PUSH
34
+ ].freeze
23
35
  end
24
36
 
25
37
  # Builds the enum from string