algolia 3.23.0 → 3.25.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.
@@ -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 Composition
10
+ class ExternalInjection
11
+ # An objectID injected into an external source.
12
+ attr_accessor :algolia_object_id
13
+
14
+ # User-defined key-values that will be added to the injected item in the response. This is identical to Hits metadata defined in Composition or Composition Rule, with the benefit of being set at runtime.
15
+ attr_accessor :metadata
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :algolia_object_id => :objectID,
21
+ :metadata => :metadata
22
+ }
23
+ end
24
+
25
+ # Attribute type mapping.
26
+ def self.types_mapping
27
+ {
28
+ :algolia_object_id => :"String",
29
+ :metadata => :"Hash<String, Object>"
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::ExternalInjection` 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::ExternalInjection`. 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?(:algolia_object_id)
64
+ self.algolia_object_id = attributes[:algolia_object_id]
65
+ else
66
+ self.algolia_object_id = nil
67
+ end
68
+
69
+ if attributes.key?(:metadata)
70
+ if (value = attributes[:metadata]).is_a?(Hash)
71
+ self.metadata = value
72
+ end
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
+ algolia_object_id == other.algolia_object_id &&
82
+ metadata == other.metadata
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
+ [algolia_object_id, metadata].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::Composition.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
@@ -22,6 +22,8 @@ module Algolia
22
22
 
23
23
  attr_accessor :_distinct_seq_id
24
24
 
25
+ attr_accessor :_extra
26
+
25
27
  attr_accessor :additional_properties
26
28
 
27
29
  # Attribute mapping from ruby-style variable name to JSON key.
@@ -31,7 +33,8 @@ module Algolia
31
33
  :_highlight_result => :_highlightResult,
32
34
  :_snippet_result => :_snippetResult,
33
35
  :_ranking_info => :_rankingInfo,
34
- :_distinct_seq_id => :_distinctSeqID
36
+ :_distinct_seq_id => :_distinctSeqID,
37
+ :_extra => :_extra
35
38
  }
36
39
  end
37
40
 
@@ -42,7 +45,8 @@ module Algolia
42
45
  :_highlight_result => :"Hash<String, HighlightResult>",
43
46
  :_snippet_result => :"Hash<String, SnippetResult>",
44
47
  :_ranking_info => :"HitRankingInfo",
45
- :_distinct_seq_id => :"Integer"
48
+ :_distinct_seq_id => :"Integer",
49
+ :_extra => :"HitMetadata"
46
50
  }
47
51
  end
48
52
 
@@ -86,6 +90,10 @@ module Algolia
86
90
  self._distinct_seq_id = attributes[:_distinct_seq_id]
87
91
  end
88
92
 
93
+ if attributes.key?(:_extra)
94
+ self._extra = attributes[:_extra]
95
+ end
96
+
89
97
  # add extra attribute to additional_properties
90
98
  self.additional_properties ||= {}
91
99
  self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
@@ -100,7 +108,8 @@ module Algolia
100
108
  _highlight_result == other._highlight_result &&
101
109
  _snippet_result == other._snippet_result &&
102
110
  _ranking_info == other._ranking_info &&
103
- _distinct_seq_id == other._distinct_seq_id
111
+ _distinct_seq_id == other._distinct_seq_id &&
112
+ _extra == other._extra
104
113
  end
105
114
 
106
115
  # @see the `==` method
@@ -112,7 +121,7 @@ module Algolia
112
121
  # Calculates hash code according to all attributes.
113
122
  # @return [Integer] Hash code
114
123
  def hash
115
- [algolia_object_id, _highlight_result, _snippet_result, _ranking_info, _distinct_seq_id].hash
124
+ [algolia_object_id, _highlight_result, _snippet_result, _ranking_info, _distinct_seq_id, _extra].hash
116
125
  end
117
126
 
118
127
  # Builds the object from hash
@@ -0,0 +1,210 @@
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
+ # An object that contains the extra key-value pairs provided in the injectedItem definition.
11
+ class HitMetadata
12
+ # The key of the injectedItem that inserted this metadata.
13
+ attr_accessor :_injected_item_key
14
+
15
+ attr_accessor :additional_properties
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :_injected_item_key => :_injectedItemKey
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.types_mapping
26
+ {
27
+ :_injected_item_key => :"String"
28
+ }
29
+ end
30
+
31
+ # List of attributes with nullable: true
32
+ def self.openapi_nullable
33
+ Set.new(
34
+ []
35
+ )
36
+ end
37
+
38
+ # Initializes the object
39
+ # @param [Hash] attributes Model attributes in the form of hash
40
+ def initialize(attributes = {})
41
+ if (!attributes.is_a?(Hash))
42
+ raise(
43
+ ArgumentError,
44
+ "The input argument (attributes) must be a hash in `Algolia::HitMetadata` initialize method"
45
+ )
46
+ end
47
+
48
+ if attributes.key?(:_injected_item_key)
49
+ self._injected_item_key = attributes[:_injected_item_key]
50
+ end
51
+
52
+ # add extra attribute to additional_properties
53
+ self.additional_properties ||= {}
54
+ self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
55
+ end
56
+
57
+ # Checks equality by comparing each attribute.
58
+ # @param [Object] Object to be compared
59
+ def ==(other)
60
+ return true if self.equal?(other)
61
+ self.class == other.class &&
62
+ _injected_item_key == other._injected_item_key
63
+ end
64
+
65
+ # @see the `==` method
66
+ # @param [Object] Object to be compared
67
+ def eql?(other)
68
+ self == other
69
+ end
70
+
71
+ # Calculates hash code according to all attributes.
72
+ # @return [Integer] Hash code
73
+ def hash
74
+ [_injected_item_key].hash
75
+ end
76
+
77
+ # Builds the object from hash
78
+ # @param [Hash] attributes Model attributes in the form of hash
79
+ # @return [Object] Returns the model itself
80
+ def self.build_from_hash(attributes)
81
+ return nil unless attributes.is_a?(Hash)
82
+ attributes = attributes.transform_keys(&:to_sym)
83
+ transformed_hash = {}
84
+ types_mapping.each_pair do |key, type|
85
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
86
+ transformed_hash[key.to_sym] = nil
87
+ elsif type =~ /\AArray<(.*)>/i
88
+ # check to ensure the input is an array given that the attribute
89
+ # is documented as an array but the input is not
90
+ if attributes[attribute_map[key]].is_a?(Array)
91
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
92
+ _deserialize(::Regexp.last_match(1), v)
93
+ }
94
+ end
95
+ elsif !attributes[attribute_map[key]].nil?
96
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
97
+ end
98
+ end
99
+
100
+ # add extra attribute to transformed_hash
101
+ transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
102
+ new(transformed_hash)
103
+ end
104
+
105
+ # Deserializes the data based on type
106
+ # @param string type Data type
107
+ # @param string value Value to be deserialized
108
+ # @return [Object] Deserialized data
109
+ def self._deserialize(type, value)
110
+ case type.to_sym
111
+ when :Time
112
+ Time.parse(value)
113
+ when :Date
114
+ Date.parse(value)
115
+ when :String
116
+ value.to_s
117
+ when :Integer
118
+ value.to_i
119
+ when :Float
120
+ value.to_f
121
+ when :Boolean
122
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
123
+ true
124
+ else
125
+ false
126
+ end
127
+
128
+ when :Object
129
+ # generic object (usually a Hash), return directly
130
+ value
131
+ when /\AArray<(?<inner_type>.+)>\z/
132
+ inner_type = Regexp.last_match[:inner_type]
133
+ value.map { |v| _deserialize(inner_type, v) }
134
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
135
+ k_type = Regexp.last_match[:k_type]
136
+ v_type = Regexp.last_match[:v_type]
137
+ {}.tap do |hash|
138
+ value.each do |k, v|
139
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
140
+ end
141
+ end
142
+ # model
143
+ else
144
+ # models (e.g. Pet) or oneOf
145
+ klass = Algolia::Composition.const_get(type)
146
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
147
+ .build_from_hash(value)
148
+ end
149
+ end
150
+
151
+ # Returns the string representation of the object
152
+ # @return [String] String presentation of the object
153
+ def to_s
154
+ to_hash.to_s
155
+ end
156
+
157
+ # to_body is an alias to to_hash (backward compatibility)
158
+ # @return [Hash] Returns the object in the form of hash
159
+ def to_body
160
+ to_hash
161
+ end
162
+
163
+ def to_json(*_args)
164
+ to_hash.to_json
165
+ end
166
+
167
+ # Returns the object in the form of hash
168
+ # @return [Hash] Returns the object in the form of hash
169
+ def to_hash
170
+ hash = {}
171
+ self.class.attribute_map.each_pair do |attr, param|
172
+ value = send(attr)
173
+ if value.nil?
174
+ is_nullable = self.class.openapi_nullable.include?(attr)
175
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
176
+ end
177
+
178
+ hash[param] = _to_hash(value)
179
+ end
180
+
181
+ # also add attributes from additional_properties to hash
182
+ self.additional_properties&.each_pair do |k, v|
183
+ hash[k.to_sym] = _to_hash(v)
184
+ end
185
+
186
+ hash
187
+ end
188
+
189
+ # Outputs non-array value in the form of hash
190
+ # For object, use to_hash. Otherwise, just return the value
191
+ # @param [Object] value Any valid value
192
+ # @return [Hash] Returns the value in the form of hash
193
+ def _to_hash(value)
194
+ if value.is_a?(Array)
195
+ value.compact.map { |v| _to_hash(v) }
196
+ elsif value.is_a?(Hash)
197
+ {}.tap do |hash|
198
+ value.each { |k, v| hash[k] = _to_hash(v) }
199
+ end
200
+ elsif value.respond_to?(:to_hash)
201
+ value.to_hash
202
+ else
203
+ value
204
+ end
205
+ end
206
+
207
+ end
208
+
209
+ end
210
+ end
@@ -20,6 +20,7 @@ module Algolia
20
20
  # Whether the run response should include detailed ranking information.
21
21
  attr_accessor :get_ranking_info
22
22
 
23
+ # Relevancy threshold below which less relevant results aren't included in the results You can only set `relevancyStrictness` on [virtual replica indices](https://www.algolia.com/doc/guides/managing-results/refine-results/sorting/in-depth/replicas/#what-are-virtual-replicas). Use this setting to strike a balance between the relevance and number of returned results.
23
24
  attr_accessor :relevancy_strictness
24
25
 
25
26
  attr_accessor :facet_filters
@@ -49,7 +50,7 @@ module Algolia
49
50
  # Coordinates of a polygon in which to search. Polygons are defined by 3 to 10,000 points. Each point is represented by its latitude and longitude. Provide multiple polygons as nested arrays. For more information, see [filtering inside polygons](https://www.algolia.com/doc/guides/managing-results/refine-results/geolocation/#filtering-inside-rectangular-or-polygonal-areas). This parameter is ignored if you also specify `insideBoundingBox`.
50
51
  attr_accessor :inside_polygon
51
52
 
52
- # Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first** **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/).
53
+ # Languages for language-specific query processing steps such as plurals, stop-word removal, and word-detection dictionaries This setting sets a default list of languages used by the `removeStopWords` and `ignorePlurals` settings. This setting also sets a dictionary for word detection in the logogram-based [CJK](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/normalization/#normalization-for-logogram-based-languages-cjk) languages. To support this, you must place the CJK language **first** **You should always specify a query language.** If you don't specify an indexing language, the search engine uses all [supported languages](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/supported-languages/), or the languages you specified with the `ignorePlurals` or `removeStopWords` parameters. This can lead to unexpected search results. For more information, see [Language-specific configuration](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/in-depth/language-specific-configurations/).
53
54
  attr_accessor :query_languages
54
55
 
55
56
  # ISO language codes that adjust settings that are useful for processing natural language queries (as opposed to keyword searches) - Sets `removeStopWords` and `ignorePlurals` to the list of provided languages. - Sets `removeWordsIfNoResults` to `allOptional`. - Adds a `natural_language` attribute to `ruleContexts` and `analyticsTags`.
@@ -79,6 +80,9 @@ module Algolia
79
80
  # Whether this search will use [Dynamic Re-Ranking](https://www.algolia.com/doc/guides/algolia-ai/re-ranking/) This setting only has an effect if you activated Dynamic Re-Ranking for this index in the Algolia dashboard.
80
81
  attr_accessor :enable_re_ranking
81
82
 
83
+ # A list of extenrally injected objectID groups into from an external source.
84
+ attr_accessor :injected_items
85
+
82
86
  # Attribute mapping from ruby-style variable name to JSON key.
83
87
  def self.attribute_map
84
88
  {
@@ -107,7 +111,8 @@ module Algolia
107
111
  :analytics => :analytics,
108
112
  :analytics_tags => :analyticsTags,
109
113
  :enable_ab_test => :enableABTest,
110
- :enable_re_ranking => :enableReRanking
114
+ :enable_re_ranking => :enableReRanking,
115
+ :injected_items => :injectedItems
111
116
  }
112
117
  end
113
118
 
@@ -139,7 +144,8 @@ module Algolia
139
144
  :analytics => :"Boolean",
140
145
  :analytics_tags => :"Array<String>",
141
146
  :enable_ab_test => :"Boolean",
142
- :enable_re_ranking => :"Boolean"
147
+ :enable_re_ranking => :"Boolean",
148
+ :injected_items => :"Hash<String, ExternalInjectedItem>"
143
149
  }
144
150
  end
145
151
 
@@ -285,6 +291,12 @@ module Algolia
285
291
  if attributes.key?(:enable_re_ranking)
286
292
  self.enable_re_ranking = attributes[:enable_re_ranking]
287
293
  end
294
+
295
+ if attributes.key?(:injected_items)
296
+ if (value = attributes[:injected_items]).is_a?(Hash)
297
+ self.injected_items = value
298
+ end
299
+ end
288
300
  end
289
301
 
290
302
  # Checks equality by comparing each attribute.
@@ -317,7 +329,8 @@ module Algolia
317
329
  analytics == other.analytics &&
318
330
  analytics_tags == other.analytics_tags &&
319
331
  enable_ab_test == other.enable_ab_test &&
320
- enable_re_ranking == other.enable_re_ranking
332
+ enable_re_ranking == other.enable_re_ranking &&
333
+ injected_items == other.injected_items
321
334
  end
322
335
 
323
336
  # @see the `==` method
@@ -355,7 +368,8 @@ module Algolia
355
368
  analytics,
356
369
  analytics_tags,
357
370
  enable_ab_test,
358
- enable_re_ranking
371
+ enable_re_ranking,
372
+ injected_items
359
373
  ].hash
360
374
  end
361
375