algolia 3.25.0 → 3.26.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 (61) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/issue.yml +1 -1
  3. data/.github/workflows/release.yml +1 -1
  4. data/CHANGELOG.md +10 -0
  5. data/Gemfile.lock +1 -1
  6. data/lib/algolia/api/composition_client.rb +765 -0
  7. data/lib/algolia/api/ingestion_client.rb +15 -4
  8. data/lib/algolia/api/search_client.rb +4 -2
  9. data/lib/algolia/models/composition/action.rb +34 -0
  10. data/lib/algolia/models/composition/advanced_syntax_features.rb +34 -0
  11. data/lib/algolia/models/composition/alternatives_as_exact.rb +36 -0
  12. data/lib/algolia/models/composition/anchoring.rb +36 -0
  13. data/lib/algolia/models/composition/base_injection_query_parameters.rb +732 -0
  14. data/lib/algolia/models/composition/batch_composition_action.rb +109 -0
  15. data/lib/algolia/models/composition/batch_params.rb +213 -0
  16. data/lib/algolia/models/composition/boolean_string.rb +34 -0
  17. data/lib/algolia/models/composition/composition.rb +244 -0
  18. data/lib/algolia/models/composition/composition_behavior.rb +210 -0
  19. data/lib/algolia/models/composition/composition_rule.rb +280 -0
  20. data/lib/algolia/models/composition/composition_rule_consequence.rb +211 -0
  21. data/lib/algolia/models/composition/composition_rules_batch_params.rb +211 -0
  22. data/lib/algolia/models/composition/composition_source.rb +210 -0
  23. data/lib/algolia/models/composition/composition_source_search.rb +220 -0
  24. data/lib/algolia/models/composition/condition.rb +238 -0
  25. data/lib/algolia/models/composition/delete_composition_action.rb +212 -0
  26. data/lib/algolia/models/composition/delete_composition_rule_action.rb +212 -0
  27. data/lib/algolia/models/composition/distinct.rb +110 -0
  28. data/lib/algolia/models/composition/exact_on_single_word_query.rb +35 -0
  29. data/lib/algolia/models/composition/external.rb +226 -0
  30. data/lib/algolia/models/composition/external_ordering.rb +34 -0
  31. data/lib/algolia/models/composition/external_source.rb +211 -0
  32. data/lib/algolia/models/composition/get_task_response.rb +210 -0
  33. data/lib/algolia/models/composition/ignore_plurals.rb +111 -0
  34. data/lib/algolia/models/composition/injected_item.rb +253 -0
  35. data/lib/algolia/models/composition/injected_item_hits_metadata.rb +222 -0
  36. data/lib/algolia/models/composition/injected_item_metadata.rb +209 -0
  37. data/lib/algolia/models/composition/injected_item_source.rb +109 -0
  38. data/lib/algolia/models/composition/injection.rb +222 -0
  39. data/lib/algolia/models/composition/list_compositions_response.rb +261 -0
  40. data/lib/algolia/models/composition/main.rb +207 -0
  41. data/lib/algolia/models/composition/main_injection_query_parameters.rb +807 -0
  42. data/lib/algolia/models/composition/multiple_batch_request.rb +221 -0
  43. data/lib/algolia/models/composition/multiple_batch_response.rb +213 -0
  44. data/lib/algolia/models/composition/optional_words.rb +110 -0
  45. data/lib/algolia/models/composition/query_type.rb +35 -0
  46. data/lib/algolia/models/composition/remove_stop_words.rb +110 -0
  47. data/lib/algolia/models/composition/remove_words_if_no_results.rb +36 -0
  48. data/lib/algolia/models/composition/rules_batch_composition_action.rb +109 -0
  49. data/lib/algolia/models/composition/rules_multiple_batch_request.rb +221 -0
  50. data/lib/algolia/models/composition/rules_multiple_batch_response.rb +211 -0
  51. data/lib/algolia/models/composition/search.rb +217 -0
  52. data/lib/algolia/models/composition/search_composition_rules_params.rb +261 -0
  53. data/lib/algolia/models/composition/search_composition_rules_response.rb +249 -0
  54. data/lib/algolia/models/composition/search_source.rb +211 -0
  55. data/lib/algolia/models/composition/task_id_response.rb +211 -0
  56. data/lib/algolia/models/composition/task_status.rb +34 -0
  57. data/lib/algolia/models/composition/time_range.rb +219 -0
  58. data/lib/algolia/models/composition/typo_tolerance.rb +110 -0
  59. data/lib/algolia/models/composition/typo_tolerance_enum.rb +36 -0
  60. data/lib/algolia/version.rb +1 -1
  61. metadata +52 -1
@@ -0,0 +1,217 @@
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 Search
11
+ # Composition Index name.
12
+ attr_accessor :index
13
+
14
+ attr_accessor :params
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :index => :index,
20
+ :params => :params
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.types_mapping
26
+ {
27
+ :index => :"String",
28
+ :params => :"BaseInjectionQueryParameters"
29
+ }
30
+ end
31
+
32
+ # List of attributes with nullable: true
33
+ def self.openapi_nullable
34
+ Set.new(
35
+ []
36
+ )
37
+ end
38
+
39
+ # Initializes the object
40
+ # @param [Hash] attributes Model attributes in the form of hash
41
+ def initialize(attributes = {})
42
+ if (!attributes.is_a?(Hash))
43
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Search` initialize method"
44
+ end
45
+
46
+ # check to see if the attribute exists and convert string to symbol for hash key
47
+ attributes = attributes.each_with_object({}) { |(k, v), h|
48
+ if (!self.class.attribute_map.key?(k.to_sym))
49
+ raise(
50
+ ArgumentError,
51
+ "`#{k}` is not a valid attribute in `Algolia::Search`. Please check the name to make sure it's valid. List of attributes: " +
52
+ self.class.attribute_map.keys.inspect
53
+ )
54
+ end
55
+
56
+ h[k.to_sym] = v
57
+ }
58
+
59
+ if attributes.key?(:index)
60
+ self.index = attributes[:index]
61
+ else
62
+ self.index = nil
63
+ end
64
+
65
+ if attributes.key?(:params)
66
+ self.params = attributes[:params]
67
+ end
68
+ end
69
+
70
+ # Checks equality by comparing each attribute.
71
+ # @param [Object] Object to be compared
72
+ def ==(other)
73
+ return true if self.equal?(other)
74
+ self.class == other.class &&
75
+ index == other.index &&
76
+ params == other.params
77
+ end
78
+
79
+ # @see the `==` method
80
+ # @param [Object] Object to be compared
81
+ def eql?(other)
82
+ self == other
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Integer] Hash code
87
+ def hash
88
+ [index, params].hash
89
+ end
90
+
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def self.build_from_hash(attributes)
95
+ return nil unless attributes.is_a?(Hash)
96
+ attributes = attributes.transform_keys(&:to_sym)
97
+ transformed_hash = {}
98
+ types_mapping.each_pair do |key, type|
99
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
100
+ transformed_hash[key.to_sym] = nil
101
+ elsif type =~ /\AArray<(.*)>/i
102
+ # check to ensure the input is an array given that the attribute
103
+ # is documented as an array but the input is not
104
+ if attributes[attribute_map[key]].is_a?(Array)
105
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
106
+ _deserialize(::Regexp.last_match(1), v)
107
+ }
108
+ end
109
+ elsif !attributes[attribute_map[key]].nil?
110
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
111
+ end
112
+ end
113
+
114
+ new(transformed_hash)
115
+ end
116
+
117
+ # Deserializes the data based on type
118
+ # @param string type Data type
119
+ # @param string value Value to be deserialized
120
+ # @return [Object] Deserialized data
121
+ def self._deserialize(type, value)
122
+ case type.to_sym
123
+ when :Time
124
+ Time.parse(value)
125
+ when :Date
126
+ Date.parse(value)
127
+ when :String
128
+ value.to_s
129
+ when :Integer
130
+ value.to_i
131
+ when :Float
132
+ value.to_f
133
+ when :Boolean
134
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
135
+ true
136
+ else
137
+ false
138
+ end
139
+
140
+ when :Object
141
+ # generic object (usually a Hash), return directly
142
+ value
143
+ when /\AArray<(?<inner_type>.+)>\z/
144
+ inner_type = Regexp.last_match[:inner_type]
145
+ value.map { |v| _deserialize(inner_type, v) }
146
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
147
+ k_type = Regexp.last_match[:k_type]
148
+ v_type = Regexp.last_match[:v_type]
149
+ {}.tap do |hash|
150
+ value.each do |k, v|
151
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
+ end
153
+ end
154
+ # model
155
+ else
156
+ # models (e.g. Pet) or oneOf
157
+ klass = Algolia::Composition.const_get(type)
158
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
159
+ .build_from_hash(value)
160
+ end
161
+ end
162
+
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_body
172
+ to_hash
173
+ end
174
+
175
+ def to_json(*_args)
176
+ to_hash.to_json
177
+ end
178
+
179
+ # Returns the object in the form of hash
180
+ # @return [Hash] Returns the object in the form of hash
181
+ def to_hash
182
+ hash = {}
183
+ self.class.attribute_map.each_pair do |attr, param|
184
+ value = send(attr)
185
+ if value.nil?
186
+ is_nullable = self.class.openapi_nullable.include?(attr)
187
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
+ end
189
+
190
+ hash[param] = _to_hash(value)
191
+ end
192
+
193
+ hash
194
+ end
195
+
196
+ # Outputs non-array value in the form of hash
197
+ # For object, use to_hash. Otherwise, just return the value
198
+ # @param [Object] value Any valid value
199
+ # @return [Hash] Returns the value in the form of hash
200
+ def _to_hash(value)
201
+ if value.is_a?(Array)
202
+ value.compact.map { |v| _to_hash(v) }
203
+ elsif value.is_a?(Hash)
204
+ {}.tap do |hash|
205
+ value.each { |k, v| hash[k] = _to_hash(v) }
206
+ end
207
+ elsif value.respond_to?(:to_hash)
208
+ value.to_hash
209
+ else
210
+ value
211
+ end
212
+ end
213
+
214
+ end
215
+
216
+ end
217
+ end
@@ -0,0 +1,261 @@
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
+ # Composition Rules search parameters.
11
+ class SearchCompositionRulesParams
12
+ # Search query for rules.
13
+ attr_accessor :query
14
+
15
+ attr_accessor :anchoring
16
+
17
+ # Only return composition rules that match the context (exact match).
18
+ attr_accessor :context
19
+
20
+ # Requested page of the API response. Algolia uses `page` and `hitsPerPage` to control how search results are displayed ([paginated](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/pagination/js/)). - `hitsPerPage`: sets the number of search results (_hits_) displayed per page. - `page`: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page is `page=0`, the second is `page=1`, and so on. For example, to display 10 results per page starting from the third page, set `hitsPerPage` to 10 and `page` to 2.
21
+ attr_accessor :page
22
+
23
+ # Maximum number of hits per page. Algolia uses `page` and `hitsPerPage` to control how search results are displayed ([paginated](https://www.algolia.com/doc/guides/building-search-ui/ui-and-ux-patterns/pagination/js/)). - `hitsPerPage`: sets the number of search results (_hits_) displayed per page. - `page`: specifies the page number of the search results you want to retrieve. Page numbering starts at 0, so the first page is `page=0`, the second is `page=1`, and so on. For example, to display 10 results per page starting from the third page, set `hitsPerPage` to 10 and `page` to 2.
24
+ attr_accessor :hits_per_page
25
+
26
+ # If `true`, return only enabled composition rules. If `false`, return only inactive composition rules. By default, _all_ composition rules are returned.
27
+ attr_accessor :enabled
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :query => :query,
33
+ :anchoring => :anchoring,
34
+ :context => :context,
35
+ :page => :page,
36
+ :hits_per_page => :hitsPerPage,
37
+ :enabled => :enabled
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.types_mapping
43
+ {
44
+ :query => :"String",
45
+ :anchoring => :"Anchoring",
46
+ :context => :"String",
47
+ :page => :"Integer",
48
+ :hits_per_page => :"Integer",
49
+ :enabled => :"Boolean"
50
+ }
51
+ end
52
+
53
+ # List of attributes with nullable: true
54
+ def self.openapi_nullable
55
+ Set.new(
56
+ [
57
+ :enabled
58
+ ]
59
+ )
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ raise(
67
+ ArgumentError,
68
+ "The input argument (attributes) must be a hash in `Algolia::SearchCompositionRulesParams` initialize method"
69
+ )
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ raise(
76
+ ArgumentError,
77
+ "`#{k}` is not a valid attribute in `Algolia::SearchCompositionRulesParams`. Please check the name to make sure it's valid. List of attributes: " +
78
+ self.class.attribute_map.keys.inspect
79
+ )
80
+ end
81
+
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:query)
86
+ self.query = attributes[:query]
87
+ end
88
+
89
+ if attributes.key?(:anchoring)
90
+ self.anchoring = attributes[:anchoring]
91
+ end
92
+
93
+ if attributes.key?(:context)
94
+ self.context = attributes[:context]
95
+ end
96
+
97
+ if attributes.key?(:page)
98
+ self.page = attributes[:page]
99
+ end
100
+
101
+ if attributes.key?(:hits_per_page)
102
+ self.hits_per_page = attributes[:hits_per_page]
103
+ end
104
+
105
+ if attributes.key?(:enabled)
106
+ self.enabled = attributes[:enabled]
107
+ end
108
+ end
109
+
110
+ # Checks equality by comparing each attribute.
111
+ # @param [Object] Object to be compared
112
+ def ==(other)
113
+ return true if self.equal?(other)
114
+ self.class == other.class &&
115
+ query == other.query &&
116
+ anchoring == other.anchoring &&
117
+ context == other.context &&
118
+ page == other.page &&
119
+ hits_per_page == other.hits_per_page &&
120
+ enabled == other.enabled
121
+ end
122
+
123
+ # @see the `==` method
124
+ # @param [Object] Object to be compared
125
+ def eql?(other)
126
+ self == other
127
+ end
128
+
129
+ # Calculates hash code according to all attributes.
130
+ # @return [Integer] Hash code
131
+ def hash
132
+ [query, anchoring, context, page, hits_per_page, enabled].hash
133
+ end
134
+
135
+ # Builds the object from hash
136
+ # @param [Hash] attributes Model attributes in the form of hash
137
+ # @return [Object] Returns the model itself
138
+ def self.build_from_hash(attributes)
139
+ return nil unless attributes.is_a?(Hash)
140
+ attributes = attributes.transform_keys(&:to_sym)
141
+ transformed_hash = {}
142
+ types_mapping.each_pair do |key, type|
143
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
144
+ transformed_hash[key.to_sym] = nil
145
+ elsif type =~ /\AArray<(.*)>/i
146
+ # check to ensure the input is an array given that the attribute
147
+ # is documented as an array but the input is not
148
+ if attributes[attribute_map[key]].is_a?(Array)
149
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
150
+ _deserialize(::Regexp.last_match(1), v)
151
+ }
152
+ end
153
+ elsif !attributes[attribute_map[key]].nil?
154
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
155
+ end
156
+ end
157
+
158
+ new(transformed_hash)
159
+ end
160
+
161
+ # Deserializes the data based on type
162
+ # @param string type Data type
163
+ # @param string value Value to be deserialized
164
+ # @return [Object] Deserialized data
165
+ def self._deserialize(type, value)
166
+ case type.to_sym
167
+ when :Time
168
+ Time.parse(value)
169
+ when :Date
170
+ Date.parse(value)
171
+ when :String
172
+ value.to_s
173
+ when :Integer
174
+ value.to_i
175
+ when :Float
176
+ value.to_f
177
+ when :Boolean
178
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
179
+ true
180
+ else
181
+ false
182
+ end
183
+
184
+ when :Object
185
+ # generic object (usually a Hash), return directly
186
+ value
187
+ when /\AArray<(?<inner_type>.+)>\z/
188
+ inner_type = Regexp.last_match[:inner_type]
189
+ value.map { |v| _deserialize(inner_type, v) }
190
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
191
+ k_type = Regexp.last_match[:k_type]
192
+ v_type = Regexp.last_match[:v_type]
193
+ {}.tap do |hash|
194
+ value.each do |k, v|
195
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
196
+ end
197
+ end
198
+ # model
199
+ else
200
+ # models (e.g. Pet) or oneOf
201
+ klass = Algolia::Composition.const_get(type)
202
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
203
+ .build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ def to_json(*_args)
220
+ to_hash.to_json
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+
237
+ hash
238
+ end
239
+
240
+ # Outputs non-array value in the form of hash
241
+ # For object, use to_hash. Otherwise, just return the value
242
+ # @param [Object] value Any valid value
243
+ # @return [Hash] Returns the value in the form of hash
244
+ def _to_hash(value)
245
+ if value.is_a?(Array)
246
+ value.compact.map { |v| _to_hash(v) }
247
+ elsif value.is_a?(Hash)
248
+ {}.tap do |hash|
249
+ value.each { |k, v| hash[k] = _to_hash(v) }
250
+ end
251
+ elsif value.respond_to?(:to_hash)
252
+ value.to_hash
253
+ else
254
+ value
255
+ end
256
+ end
257
+
258
+ end
259
+
260
+ end
261
+ end