algolia 3.37.0 → 3.38.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/algolia/api/monitoring_client.rb +2 -2
  5. data/lib/algolia/models/composition/{external.rb → injected_item_external.rb} +6 -3
  6. data/lib/algolia/models/composition/{external_source.rb → injected_item_external_source.rb} +11 -4
  7. data/lib/algolia/models/composition/injected_item_recommend_source.rb +216 -0
  8. data/lib/algolia/models/composition/{search.rb → injected_item_search.rb} +6 -3
  9. data/lib/algolia/models/composition/{search_source.rb → injected_item_search_source.rb} +11 -4
  10. data/lib/algolia/models/composition/injected_item_source.rb +3 -2
  11. data/lib/algolia/models/composition/injection.rb +2 -2
  12. data/lib/algolia/models/composition/{injected_item.rb → injection_injected_item.rb} +3 -3
  13. data/lib/algolia/models/composition/{main.rb → injection_main.rb} +8 -6
  14. data/lib/algolia/models/composition/injection_main_recommend_source.rb +216 -0
  15. data/lib/algolia/models/composition/{composition_source.rb → injection_main_search_source.rb} +12 -4
  16. data/lib/algolia/models/composition/injection_main_source.rb +109 -0
  17. data/lib/algolia/models/composition/main_recommend.rb +250 -0
  18. data/lib/algolia/models/composition/{composition_source_search.rb → main_search.rb} +4 -4
  19. data/lib/algolia/models/composition/model.rb +33 -0
  20. data/lib/algolia/models/composition/recommend.rb +250 -0
  21. data/lib/algolia/models/search/auto_filtering_filter_entry.rb +108 -0
  22. data/lib/algolia/models/search/auto_filtering_result.rb +242 -0
  23. data/lib/algolia/models/search/browse_response.rb +10 -0
  24. data/lib/algolia/models/search/category_prediction.rb +218 -0
  25. data/lib/algolia/models/search/category_prediction_bin.rb +37 -0
  26. data/lib/algolia/models/search/hierarchy_path_entry.rb +227 -0
  27. data/lib/algolia/models/search/query_categorization.rb +248 -0
  28. data/lib/algolia/models/search/query_categorization_type.rb +36 -0
  29. data/lib/algolia/models/search/response_extensions.rb +207 -0
  30. data/lib/algolia/models/search/search_extensions.rb +207 -0
  31. data/lib/algolia/models/search/search_extensions_query_categorization.rb +218 -0
  32. data/lib/algolia/models/search/search_for_hits.rb +14 -4
  33. data/lib/algolia/models/search/search_response.rb +14 -4
  34. data/lib/algolia/version.rb +1 -1
  35. metadata +25 -9
@@ -0,0 +1,218 @@
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
+ class CategoryPrediction
11
+ attr_accessor :bin
12
+
13
+ # Ordered list of category levels from root to the predicted category.
14
+ attr_accessor :hierarchy_path
15
+
16
+ # Attribute mapping from ruby-style variable name to JSON key.
17
+ def self.attribute_map
18
+ {
19
+ :bin => :bin,
20
+ :hierarchy_path => :hierarchyPath
21
+ }
22
+ end
23
+
24
+ # Attribute type mapping.
25
+ def self.types_mapping
26
+ {
27
+ :bin => :"CategoryPredictionBin",
28
+ :hierarchy_path => :"Array<HierarchyPathEntry>"
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(
44
+ ArgumentError,
45
+ "The input argument (attributes) must be a hash in `Algolia::CategoryPrediction` initialize method"
46
+ )
47
+ end
48
+
49
+ # check to see if the attribute exists and convert string to symbol for hash key
50
+ attributes = attributes.each_with_object({}) { |(k, v), h|
51
+ if (!self.class.attribute_map.key?(k.to_sym))
52
+ raise(
53
+ ArgumentError,
54
+ "`#{k}` is not a valid attribute in `Algolia::CategoryPrediction`. Please check the name to make sure it's valid. List of attributes: " +
55
+ self.class.attribute_map.keys.inspect
56
+ )
57
+ end
58
+
59
+ h[k.to_sym] = v
60
+ }
61
+
62
+ if attributes.key?(:bin)
63
+ self.bin = attributes[:bin]
64
+ end
65
+
66
+ if attributes.key?(:hierarchy_path)
67
+ if (value = attributes[:hierarchy_path]).is_a?(Array)
68
+ self.hierarchy_path = value
69
+ end
70
+ end
71
+ end
72
+
73
+ # Checks equality by comparing each attribute.
74
+ # @param [Object] Object to be compared
75
+ def ==(other)
76
+ return true if self.equal?(other)
77
+ self.class == other.class &&
78
+ bin == other.bin &&
79
+ hierarchy_path == other.hierarchy_path
80
+ end
81
+
82
+ # @see the `==` method
83
+ # @param [Object] Object to be compared
84
+ def eql?(other)
85
+ self == other
86
+ end
87
+
88
+ # Calculates hash code according to all attributes.
89
+ # @return [Integer] Hash code
90
+ def hash
91
+ [bin, hierarchy_path].hash
92
+ end
93
+
94
+ # Builds the object from hash
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ # @return [Object] Returns the model itself
97
+ def self.build_from_hash(attributes)
98
+ return nil unless attributes.is_a?(Hash)
99
+ attributes = attributes.transform_keys(&:to_sym)
100
+ transformed_hash = {}
101
+ types_mapping.each_pair do |key, type|
102
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
103
+ transformed_hash[key.to_sym] = nil
104
+ elsif type =~ /\AArray<(.*)>/i
105
+ # check to ensure the input is an array given that the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[attribute_map[key]].is_a?(Array)
108
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
109
+ _deserialize(::Regexp.last_match(1), v)
110
+ }
111
+ end
112
+ elsif !attributes[attribute_map[key]].nil?
113
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
114
+ end
115
+ end
116
+
117
+ new(transformed_hash)
118
+ end
119
+
120
+ # Deserializes the data based on type
121
+ # @param string type Data type
122
+ # @param string value Value to be deserialized
123
+ # @return [Object] Deserialized data
124
+ def self._deserialize(type, value)
125
+ case type.to_sym
126
+ when :Time
127
+ Time.parse(value)
128
+ when :Date
129
+ Date.parse(value)
130
+ when :String
131
+ value.to_s
132
+ when :Integer
133
+ value.to_i
134
+ when :Float
135
+ value.to_f
136
+ when :Boolean
137
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
138
+ true
139
+ else
140
+ false
141
+ end
142
+
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ # model
158
+ else
159
+ # models (e.g. Pet) or oneOf
160
+ klass = Algolia::Search.const_get(type)
161
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
162
+ .build_from_hash(value)
163
+ end
164
+ end
165
+
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
168
+ def to_s
169
+ to_hash.to_s
170
+ end
171
+
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_body
175
+ to_hash
176
+ end
177
+
178
+ def to_json(*_args)
179
+ to_hash.to_json
180
+ end
181
+
182
+ # Returns the object in the form of hash
183
+ # @return [Hash] Returns the object in the form of hash
184
+ def to_hash
185
+ hash = {}
186
+ self.class.attribute_map.each_pair do |attr, param|
187
+ value = send(attr)
188
+ if value.nil?
189
+ is_nullable = self.class.openapi_nullable.include?(attr)
190
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
191
+ end
192
+
193
+ hash[param] = _to_hash(value)
194
+ end
195
+
196
+ hash
197
+ end
198
+
199
+ # Outputs non-array value in the form of hash
200
+ # For object, use to_hash. Otherwise, just return the value
201
+ # @param [Object] value Any valid value
202
+ # @return [Hash] Returns the value in the form of hash
203
+ def _to_hash(value)
204
+ if value.is_a?(Array)
205
+ value.compact.map { |v| _to_hash(v) }
206
+ elsif value.is_a?(Hash)
207
+ {}.tap do |hash|
208
+ value.each { |k, v| hash[k] = _to_hash(v) }
209
+ end
210
+ elsif value.respond_to?(:to_hash)
211
+ value.to_hash
212
+ else
213
+ value
214
+ end
215
+ end
216
+ end
217
+ end
218
+ end
@@ -0,0 +1,37 @@
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
+ class CategoryPredictionBin
11
+ CERTAIN = "certain".freeze
12
+ VERY_HIGH = "very high".freeze
13
+ HIGH = "high".freeze
14
+ LOW = "low".freeze
15
+ VERY_LOW = "very low".freeze
16
+
17
+ def self.all_vars
18
+ @all_vars ||= [CERTAIN, VERY_HIGH, HIGH, LOW, VERY_LOW].freeze
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def self.build_from_hash(value)
25
+ new.build_from_hash(value)
26
+ end
27
+
28
+ # Builds the enum from string
29
+ # @param [String] The enum value in the form of the string
30
+ # @return [String] The enum value
31
+ def build_from_hash(value)
32
+ return value if CategoryPredictionBin.all_vars.include?(value)
33
+ raise "Invalid ENUM value #{value} for class #CategoryPredictionBin"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -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 Search
10
+ class HierarchyPathEntry
11
+ # Facet attribute name at this hierarchy level, for example, `categories.lvl0`.
12
+ attr_accessor :facet_name
13
+
14
+ # Facet value at this level of the category hierarchy.
15
+ attr_accessor :facet_value
16
+
17
+ # Depth level in the category hierarchy, starting at 0.
18
+ attr_accessor :depth
19
+
20
+ # Attribute mapping from ruby-style variable name to JSON key.
21
+ def self.attribute_map
22
+ {
23
+ :facet_name => :facetName,
24
+ :facet_value => :facetValue,
25
+ :depth => :depth
26
+ }
27
+ end
28
+
29
+ # Attribute type mapping.
30
+ def self.types_mapping
31
+ {
32
+ :facet_name => :"String",
33
+ :facet_value => :"String",
34
+ :depth => :"Integer"
35
+ }
36
+ end
37
+
38
+ # List of attributes with nullable: true
39
+ def self.openapi_nullable
40
+ Set.new(
41
+ []
42
+ )
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ if (!attributes.is_a?(Hash))
49
+ raise(
50
+ ArgumentError,
51
+ "The input argument (attributes) must be a hash in `Algolia::HierarchyPathEntry` initialize method"
52
+ )
53
+ end
54
+
55
+ # check to see if the attribute exists and convert string to symbol for hash key
56
+ attributes = attributes.each_with_object({}) { |(k, v), h|
57
+ if (!self.class.attribute_map.key?(k.to_sym))
58
+ raise(
59
+ ArgumentError,
60
+ "`#{k}` is not a valid attribute in `Algolia::HierarchyPathEntry`. Please check the name to make sure it's valid. List of attributes: " +
61
+ self.class.attribute_map.keys.inspect
62
+ )
63
+ end
64
+
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:facet_name)
69
+ self.facet_name = attributes[:facet_name]
70
+ end
71
+
72
+ if attributes.key?(:facet_value)
73
+ self.facet_value = attributes[:facet_value]
74
+ end
75
+
76
+ if attributes.key?(:depth)
77
+ self.depth = attributes[:depth]
78
+ end
79
+ end
80
+
81
+ # Checks equality by comparing each attribute.
82
+ # @param [Object] Object to be compared
83
+ def ==(other)
84
+ return true if self.equal?(other)
85
+ self.class == other.class &&
86
+ facet_name == other.facet_name &&
87
+ facet_value == other.facet_value &&
88
+ depth == other.depth
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
+ [facet_name, facet_value, depth].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::Search.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