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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/monitoring_client.rb +2 -2
- data/lib/algolia/models/composition/{external.rb → injected_item_external.rb} +6 -3
- data/lib/algolia/models/composition/{external_source.rb → injected_item_external_source.rb} +11 -4
- data/lib/algolia/models/composition/injected_item_recommend_source.rb +216 -0
- data/lib/algolia/models/composition/{search.rb → injected_item_search.rb} +6 -3
- data/lib/algolia/models/composition/{search_source.rb → injected_item_search_source.rb} +11 -4
- data/lib/algolia/models/composition/injected_item_source.rb +3 -2
- data/lib/algolia/models/composition/injection.rb +2 -2
- data/lib/algolia/models/composition/{injected_item.rb → injection_injected_item.rb} +3 -3
- data/lib/algolia/models/composition/{main.rb → injection_main.rb} +8 -6
- data/lib/algolia/models/composition/injection_main_recommend_source.rb +216 -0
- data/lib/algolia/models/composition/{composition_source.rb → injection_main_search_source.rb} +12 -4
- data/lib/algolia/models/composition/injection_main_source.rb +109 -0
- data/lib/algolia/models/composition/main_recommend.rb +250 -0
- data/lib/algolia/models/composition/{composition_source_search.rb → main_search.rb} +4 -4
- data/lib/algolia/models/composition/model.rb +33 -0
- data/lib/algolia/models/composition/recommend.rb +250 -0
- data/lib/algolia/models/search/auto_filtering_filter_entry.rb +108 -0
- data/lib/algolia/models/search/auto_filtering_result.rb +242 -0
- data/lib/algolia/models/search/browse_response.rb +10 -0
- data/lib/algolia/models/search/category_prediction.rb +218 -0
- data/lib/algolia/models/search/category_prediction_bin.rb +37 -0
- data/lib/algolia/models/search/hierarchy_path_entry.rb +227 -0
- data/lib/algolia/models/search/query_categorization.rb +248 -0
- data/lib/algolia/models/search/query_categorization_type.rb +36 -0
- data/lib/algolia/models/search/response_extensions.rb +207 -0
- data/lib/algolia/models/search/search_extensions.rb +207 -0
- data/lib/algolia/models/search/search_extensions_query_categorization.rb +218 -0
- data/lib/algolia/models/search/search_for_hits.rb +14 -4
- data/lib/algolia/models/search/search_response.rb +14 -4
- data/lib/algolia/version.rb +1 -1
- metadata +25 -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
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
module AutoFilteringFilterEntry
|
|
11
|
+
class << self
|
|
12
|
+
# List of class defined in oneOf (OpenAPI v3)
|
|
13
|
+
def openapi_one_of
|
|
14
|
+
[
|
|
15
|
+
:"Array<String>",
|
|
16
|
+
:"String"
|
|
17
|
+
]
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Builds the object
|
|
21
|
+
# @param [Mixed] Data to be matched against the list of oneOf items
|
|
22
|
+
# @return [Object] Returns the model or the data itself
|
|
23
|
+
def build(data)
|
|
24
|
+
# Go through the list of oneOf items and attempt to identify the appropriate one.
|
|
25
|
+
# Note:
|
|
26
|
+
# - We do not attempt to check whether exactly one item matches.
|
|
27
|
+
# - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 })
|
|
28
|
+
# due to the way the deserialization is made in the base_object template (it just casts without verifying).
|
|
29
|
+
# - TODO: scalar values are de facto behaving as if they were nullable.
|
|
30
|
+
# - TODO: logging when debugging is set.
|
|
31
|
+
openapi_one_of.each do |klass|
|
|
32
|
+
begin
|
|
33
|
+
# "nullable: true"
|
|
34
|
+
next if klass == :AnyType
|
|
35
|
+
typed_data = find_and_cast_into_type(klass, data)
|
|
36
|
+
return typed_data if typed_data
|
|
37
|
+
# rescue all errors so we keep iterating even if the current item lookup raises
|
|
38
|
+
rescue
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
openapi_one_of.include?(:AnyType) ? data : nil
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
SchemaMismatchError = Class.new(StandardError)
|
|
48
|
+
|
|
49
|
+
def find_and_cast_into_type(klass, data)
|
|
50
|
+
return if data.nil?
|
|
51
|
+
|
|
52
|
+
case klass.to_s
|
|
53
|
+
when "Boolean"
|
|
54
|
+
return data if data.instance_of?(TrueClass) || data.instance_of?(FalseClass)
|
|
55
|
+
when "Float"
|
|
56
|
+
return data if data.instance_of?(Float)
|
|
57
|
+
when "Integer"
|
|
58
|
+
return data if data.instance_of?(Integer)
|
|
59
|
+
when "Time"
|
|
60
|
+
return Time.parse(data)
|
|
61
|
+
when "Date"
|
|
62
|
+
return Date.parse(data)
|
|
63
|
+
when "String"
|
|
64
|
+
return data if data.instance_of?(String)
|
|
65
|
+
# "type: object"
|
|
66
|
+
when "Object"
|
|
67
|
+
return data if data.instance_of?(Hash)
|
|
68
|
+
# "type: array"
|
|
69
|
+
when /\AArray<(?<sub_type>.+)>\z/
|
|
70
|
+
if data.instance_of?(Array)
|
|
71
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
72
|
+
return data.map { |item| find_and_cast_into_type(sub_type, item) }
|
|
73
|
+
end
|
|
74
|
+
# "type: object" with "additionalProperties: { ... }"
|
|
75
|
+
when /\AHash<String, (?<sub_type>.+)>\z/
|
|
76
|
+
if data.instance_of?(Hash) && data.keys.all? { |k| k.instance_of?(Symbol) || k.instance_of?(String) }
|
|
77
|
+
sub_type = Regexp.last_match[:sub_type]
|
|
78
|
+
return data.each_with_object({}) { |(k, v), hsh| hsh[k] = find_and_cast_into_type(sub_type, v) }
|
|
79
|
+
end
|
|
80
|
+
# model
|
|
81
|
+
else
|
|
82
|
+
const = Algolia::Search.const_get(klass)
|
|
83
|
+
if const
|
|
84
|
+
if const.respond_to?(:openapi_one_of)
|
|
85
|
+
# nested oneOf model
|
|
86
|
+
model = const.build(data)
|
|
87
|
+
elsif const.respond_to?(:discriminator_attributes)
|
|
88
|
+
if const.discriminator_attributes.all? { |attr| data.key?(attr) }
|
|
89
|
+
model = const.build_from_hash(data)
|
|
90
|
+
end
|
|
91
|
+
else
|
|
92
|
+
# maybe it's an enum, or doens't have discriminators
|
|
93
|
+
model = const.build_from_hash(data)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
return model if model
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# if no match by now, raise
|
|
101
|
+
raise
|
|
102
|
+
rescue
|
|
103
|
+
raise SchemaMismatchError, "#{data} doesn't match the #{klass} type"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
@@ -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
|
+
# Result of automatic filtering applied by Query Categorization.
|
|
11
|
+
class AutoFilteringResult
|
|
12
|
+
# Whether automatic filtering was applied to this query.
|
|
13
|
+
attr_accessor :enabled
|
|
14
|
+
|
|
15
|
+
# Maximum category hierarchy depth used for filtering.
|
|
16
|
+
attr_accessor :max_depth
|
|
17
|
+
|
|
18
|
+
# Facet filters automatically applied to the query.
|
|
19
|
+
attr_accessor :facet_filters
|
|
20
|
+
|
|
21
|
+
# Optional filters automatically applied to boost relevant categories.
|
|
22
|
+
attr_accessor :optional_filters
|
|
23
|
+
|
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
|
25
|
+
def self.attribute_map
|
|
26
|
+
{
|
|
27
|
+
:enabled => :enabled,
|
|
28
|
+
:max_depth => :maxDepth,
|
|
29
|
+
:facet_filters => :facetFilters,
|
|
30
|
+
:optional_filters => :optionalFilters
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Attribute type mapping.
|
|
35
|
+
def self.types_mapping
|
|
36
|
+
{
|
|
37
|
+
:enabled => :"Boolean",
|
|
38
|
+
:max_depth => :"Integer",
|
|
39
|
+
:facet_filters => :"Array<AutoFilteringFilterEntry>",
|
|
40
|
+
:optional_filters => :"Array<AutoFilteringFilterEntry>"
|
|
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::AutoFilteringResult` 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::AutoFilteringResult`. 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?(:enabled)
|
|
75
|
+
self.enabled = attributes[:enabled]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
if attributes.key?(:max_depth)
|
|
79
|
+
self.max_depth = attributes[:max_depth]
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
if attributes.key?(:facet_filters)
|
|
83
|
+
if (value = attributes[:facet_filters]).is_a?(Array)
|
|
84
|
+
self.facet_filters = value
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
if attributes.key?(:optional_filters)
|
|
89
|
+
if (value = attributes[:optional_filters]).is_a?(Array)
|
|
90
|
+
self.optional_filters = 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
|
+
enabled == other.enabled &&
|
|
101
|
+
max_depth == other.max_depth &&
|
|
102
|
+
facet_filters == other.facet_filters &&
|
|
103
|
+
optional_filters == other.optional_filters
|
|
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
|
+
[enabled, max_depth, facet_filters, optional_filters].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
|
|
@@ -104,6 +104,8 @@ module Algolia
|
|
|
104
104
|
# URL-encoded string of all search parameters.
|
|
105
105
|
attr_accessor :params
|
|
106
106
|
|
|
107
|
+
attr_accessor :extensions
|
|
108
|
+
|
|
107
109
|
# Cursor to get the next page of the response. The parameter must match the value returned in the response of a previous request. The last page of the response does not return a `cursor` attribute.
|
|
108
110
|
attr_accessor :cursor
|
|
109
111
|
|
|
@@ -143,6 +145,7 @@ module Algolia
|
|
|
143
145
|
:hits => :hits,
|
|
144
146
|
:query => :query,
|
|
145
147
|
:params => :params,
|
|
148
|
+
:extensions => :extensions,
|
|
146
149
|
:cursor => :cursor
|
|
147
150
|
}
|
|
148
151
|
end
|
|
@@ -183,6 +186,7 @@ module Algolia
|
|
|
183
186
|
:hits => :"Array<Hit>",
|
|
184
187
|
:query => :"String",
|
|
185
188
|
:params => :"String",
|
|
189
|
+
:extensions => :"ResponseExtensions",
|
|
186
190
|
:cursor => :"String"
|
|
187
191
|
}
|
|
188
192
|
end
|
|
@@ -371,6 +375,10 @@ module Algolia
|
|
|
371
375
|
self.params = attributes[:params]
|
|
372
376
|
end
|
|
373
377
|
|
|
378
|
+
if attributes.key?(:extensions)
|
|
379
|
+
self.extensions = attributes[:extensions]
|
|
380
|
+
end
|
|
381
|
+
|
|
374
382
|
if attributes.key?(:cursor)
|
|
375
383
|
self.cursor = attributes[:cursor]
|
|
376
384
|
end
|
|
@@ -414,6 +422,7 @@ module Algolia
|
|
|
414
422
|
hits == other.hits &&
|
|
415
423
|
query == other.query &&
|
|
416
424
|
params == other.params &&
|
|
425
|
+
extensions == other.extensions &&
|
|
417
426
|
cursor == other.cursor
|
|
418
427
|
end
|
|
419
428
|
|
|
@@ -460,6 +469,7 @@ module Algolia
|
|
|
460
469
|
hits,
|
|
461
470
|
query,
|
|
462
471
|
params,
|
|
472
|
+
extensions,
|
|
463
473
|
cursor
|
|
464
474
|
].hash
|
|
465
475
|
end
|