algolia 3.4.0 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/api/analytics_client.rb +144 -32
- data/lib/algolia/api/search_client.rb +16 -16
- data/lib/algolia/models/recommend/banner.rb +218 -0
- data/lib/algolia/models/recommend/banner_image.rb +221 -0
- data/lib/algolia/models/recommend/banner_image_url.rb +212 -0
- data/lib/algolia/models/recommend/banner_link.rb +212 -0
- data/lib/algolia/models/recommend/banners.rb +209 -0
- data/lib/algolia/models/recommend/fallback_params.rb +8 -8
- data/lib/algolia/models/recommend/numeric_filters.rb +1 -1
- data/lib/algolia/models/recommend/recommend_search_params.rb +8 -8
- data/lib/algolia/models/recommend/rendering_content.rb +14 -5
- data/lib/algolia/models/recommend/typo_tolerance.rb +1 -1
- data/lib/algolia/models/recommend/widgets.rb +209 -0
- data/lib/algolia/models/search/api_key.rb +1 -1
- data/lib/algolia/models/search/banner.rb +218 -0
- data/lib/algolia/models/search/banner_image.rb +221 -0
- data/lib/algolia/models/search/banner_image_url.rb +212 -0
- data/lib/algolia/models/search/banner_link.rb +212 -0
- data/lib/algolia/models/search/banners.rb +209 -0
- data/lib/algolia/models/search/browse_params_object.rb +4 -4
- data/lib/algolia/models/search/consequence_params.rb +4 -4
- data/lib/algolia/models/search/delete_by_params.rb +1 -1
- data/lib/algolia/models/search/get_api_key_response.rb +1 -1
- data/lib/algolia/models/search/index_settings.rb +7 -7
- data/lib/algolia/models/search/numeric_filters.rb +1 -1
- data/lib/algolia/models/search/rendering_content.rb +14 -5
- data/lib/algolia/models/search/search_for_facets.rb +4 -4
- data/lib/algolia/models/search/search_for_hits.rb +4 -4
- data/lib/algolia/models/search/search_params_object.rb +4 -4
- data/lib/algolia/models/search/settings_response.rb +7 -7
- data/lib/algolia/models/search/typo_tolerance.rb +1 -1
- data/lib/algolia/models/search/widgets.rb +209 -0
- data/lib/algolia/version.rb +1 -1
- metadata +14 -2
@@ -0,0 +1,212 @@
|
|
1
|
+
# 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.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Search
|
8
|
+
# url for a search banner image.
|
9
|
+
class BannerImageUrl
|
10
|
+
attr_accessor :url
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
:url => :url
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns all the JSON keys this model knows about
|
20
|
+
def self.acceptable_attributes
|
21
|
+
attribute_map.values
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.types_mapping
|
26
|
+
{
|
27
|
+
:url => :"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::BannerImageUrl` initialize method"
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
51
|
+
raise(
|
52
|
+
ArgumentError,
|
53
|
+
"`#{k}` is not a valid attribute in `Algolia::BannerImageUrl`. Please check the name to make sure it's valid. List of attributes: " +
|
54
|
+
self.class.attribute_map.keys.inspect
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
h[k.to_sym] = v
|
59
|
+
}
|
60
|
+
|
61
|
+
if attributes.key?(:url)
|
62
|
+
self.url = attributes[:url]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(other)
|
69
|
+
return true if self.equal?(other)
|
70
|
+
self.class == other.class &&
|
71
|
+
url == other.url
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(other)
|
77
|
+
self == other
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Integer] Hash code
|
82
|
+
def hash
|
83
|
+
[url].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def self.build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
attributes = attributes.transform_keys(&:to_sym)
|
92
|
+
transformed_hash = {}
|
93
|
+
types_mapping.each_pair do |key, type|
|
94
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
95
|
+
transformed_hash[key.to_sym] = nil
|
96
|
+
elsif type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
100
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
101
|
+
_deserialize(::Regexp.last_match(1), v)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
elsif !attributes[attribute_map[key]].nil?
|
105
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
new(transformed_hash)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserializes the data based on type
|
113
|
+
# @param string type Data type
|
114
|
+
# @param string value Value to be deserialized
|
115
|
+
# @return [Object] Deserialized data
|
116
|
+
def self._deserialize(type, value)
|
117
|
+
case type.to_sym
|
118
|
+
when :Time
|
119
|
+
Time.parse(value)
|
120
|
+
when :Date
|
121
|
+
Date.parse(value)
|
122
|
+
when :String
|
123
|
+
value.to_s
|
124
|
+
when :Integer
|
125
|
+
value.to_i
|
126
|
+
when :Float
|
127
|
+
value.to_f
|
128
|
+
when :Boolean
|
129
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
+
true
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
when :Object
|
136
|
+
# generic object (usually a Hash), return directly
|
137
|
+
value
|
138
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
139
|
+
inner_type = Regexp.last_match[:inner_type]
|
140
|
+
value.map { |v| _deserialize(inner_type, v) }
|
141
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
142
|
+
k_type = Regexp.last_match[:k_type]
|
143
|
+
v_type = Regexp.last_match[:v_type]
|
144
|
+
{}.tap do |hash|
|
145
|
+
value.each do |k, v|
|
146
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
# model
|
150
|
+
else
|
151
|
+
# models (e.g. Pet) or oneOf
|
152
|
+
klass = Algolia::Search.const_get(type)
|
153
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
154
|
+
.build_from_hash(value)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the string representation of the object
|
159
|
+
# @return [String] String presentation of the object
|
160
|
+
def to_s
|
161
|
+
to_hash.to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
# to_body is an alias to to_hash (backward compatibility)
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_body
|
167
|
+
to_hash
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_json(*_args)
|
171
|
+
to_hash.to_json
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = send(attr)
|
180
|
+
if value.nil?
|
181
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
182
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
183
|
+
end
|
184
|
+
|
185
|
+
hash[param] = _to_hash(value)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,212 @@
|
|
1
|
+
# 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.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Search
|
8
|
+
# link for a banner defined in merchandising studio.
|
9
|
+
class BannerLink
|
10
|
+
attr_accessor :url
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
:url => :url
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns all the JSON keys this model knows about
|
20
|
+
def self.acceptable_attributes
|
21
|
+
attribute_map.values
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.types_mapping
|
26
|
+
{
|
27
|
+
:url => :"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::BannerLink` initialize method"
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
49
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
50
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
51
|
+
raise(
|
52
|
+
ArgumentError,
|
53
|
+
"`#{k}` is not a valid attribute in `Algolia::BannerLink`. Please check the name to make sure it's valid. List of attributes: " +
|
54
|
+
self.class.attribute_map.keys.inspect
|
55
|
+
)
|
56
|
+
end
|
57
|
+
|
58
|
+
h[k.to_sym] = v
|
59
|
+
}
|
60
|
+
|
61
|
+
if attributes.key?(:url)
|
62
|
+
self.url = attributes[:url]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Checks equality by comparing each attribute.
|
67
|
+
# @param [Object] Object to be compared
|
68
|
+
def ==(other)
|
69
|
+
return true if self.equal?(other)
|
70
|
+
self.class == other.class &&
|
71
|
+
url == other.url
|
72
|
+
end
|
73
|
+
|
74
|
+
# @see the `==` method
|
75
|
+
# @param [Object] Object to be compared
|
76
|
+
def eql?(other)
|
77
|
+
self == other
|
78
|
+
end
|
79
|
+
|
80
|
+
# Calculates hash code according to all attributes.
|
81
|
+
# @return [Integer] Hash code
|
82
|
+
def hash
|
83
|
+
[url].hash
|
84
|
+
end
|
85
|
+
|
86
|
+
# Builds the object from hash
|
87
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
88
|
+
# @return [Object] Returns the model itself
|
89
|
+
def self.build_from_hash(attributes)
|
90
|
+
return nil unless attributes.is_a?(Hash)
|
91
|
+
attributes = attributes.transform_keys(&:to_sym)
|
92
|
+
transformed_hash = {}
|
93
|
+
types_mapping.each_pair do |key, type|
|
94
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
95
|
+
transformed_hash[key.to_sym] = nil
|
96
|
+
elsif type =~ /\AArray<(.*)>/i
|
97
|
+
# check to ensure the input is an array given that the attribute
|
98
|
+
# is documented as an array but the input is not
|
99
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
100
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
101
|
+
_deserialize(::Regexp.last_match(1), v)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
elsif !attributes[attribute_map[key]].nil?
|
105
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
new(transformed_hash)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deserializes the data based on type
|
113
|
+
# @param string type Data type
|
114
|
+
# @param string value Value to be deserialized
|
115
|
+
# @return [Object] Deserialized data
|
116
|
+
def self._deserialize(type, value)
|
117
|
+
case type.to_sym
|
118
|
+
when :Time
|
119
|
+
Time.parse(value)
|
120
|
+
when :Date
|
121
|
+
Date.parse(value)
|
122
|
+
when :String
|
123
|
+
value.to_s
|
124
|
+
when :Integer
|
125
|
+
value.to_i
|
126
|
+
when :Float
|
127
|
+
value.to_f
|
128
|
+
when :Boolean
|
129
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
130
|
+
true
|
131
|
+
else
|
132
|
+
false
|
133
|
+
end
|
134
|
+
|
135
|
+
when :Object
|
136
|
+
# generic object (usually a Hash), return directly
|
137
|
+
value
|
138
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
139
|
+
inner_type = Regexp.last_match[:inner_type]
|
140
|
+
value.map { |v| _deserialize(inner_type, v) }
|
141
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
142
|
+
k_type = Regexp.last_match[:k_type]
|
143
|
+
v_type = Regexp.last_match[:v_type]
|
144
|
+
{}.tap do |hash|
|
145
|
+
value.each do |k, v|
|
146
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
# model
|
150
|
+
else
|
151
|
+
# models (e.g. Pet) or oneOf
|
152
|
+
klass = Algolia::Search.const_get(type)
|
153
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
154
|
+
.build_from_hash(value)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns the string representation of the object
|
159
|
+
# @return [String] String presentation of the object
|
160
|
+
def to_s
|
161
|
+
to_hash.to_s
|
162
|
+
end
|
163
|
+
|
164
|
+
# to_body is an alias to to_hash (backward compatibility)
|
165
|
+
# @return [Hash] Returns the object in the form of hash
|
166
|
+
def to_body
|
167
|
+
to_hash
|
168
|
+
end
|
169
|
+
|
170
|
+
def to_json(*_args)
|
171
|
+
to_hash.to_json
|
172
|
+
end
|
173
|
+
|
174
|
+
# Returns the object in the form of hash
|
175
|
+
# @return [Hash] Returns the object in the form of hash
|
176
|
+
def to_hash
|
177
|
+
hash = {}
|
178
|
+
self.class.attribute_map.each_pair do |attr, param|
|
179
|
+
value = send(attr)
|
180
|
+
if value.nil?
|
181
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
182
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
183
|
+
end
|
184
|
+
|
185
|
+
hash[param] = _to_hash(value)
|
186
|
+
end
|
187
|
+
|
188
|
+
hash
|
189
|
+
end
|
190
|
+
|
191
|
+
# Outputs non-array value in the form of hash
|
192
|
+
# For object, use to_hash. Otherwise, just return the value
|
193
|
+
# @param [Object] value Any valid value
|
194
|
+
# @return [Hash] Returns the value in the form of hash
|
195
|
+
def _to_hash(value)
|
196
|
+
if value.is_a?(Array)
|
197
|
+
value.compact.map { |v| _to_hash(v) }
|
198
|
+
elsif value.is_a?(Hash)
|
199
|
+
{}.tap do |hash|
|
200
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
201
|
+
end
|
202
|
+
elsif value.respond_to?(:to_hash)
|
203
|
+
value.to_hash
|
204
|
+
else
|
205
|
+
value
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
|
211
|
+
end
|
212
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# 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.
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "time"
|
5
|
+
|
6
|
+
module Algolia
|
7
|
+
module Search
|
8
|
+
# banners defined in the merchandising studio for the given search.
|
9
|
+
class Banners
|
10
|
+
attr_accessor :banners
|
11
|
+
|
12
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
13
|
+
def self.attribute_map
|
14
|
+
{
|
15
|
+
:banners => :banners
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns all the JSON keys this model knows about
|
20
|
+
def self.acceptable_attributes
|
21
|
+
attribute_map.values
|
22
|
+
end
|
23
|
+
|
24
|
+
# Attribute type mapping.
|
25
|
+
def self.types_mapping
|
26
|
+
{
|
27
|
+
:banners => :"Banner"
|
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 ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Banners` initialize method"
|
43
|
+
end
|
44
|
+
|
45
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
46
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
47
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
48
|
+
raise(
|
49
|
+
ArgumentError,
|
50
|
+
"`#{k}` is not a valid attribute in `Algolia::Banners`. Please check the name to make sure it's valid. List of attributes: " +
|
51
|
+
self.class.attribute_map.keys.inspect
|
52
|
+
)
|
53
|
+
end
|
54
|
+
|
55
|
+
h[k.to_sym] = v
|
56
|
+
}
|
57
|
+
|
58
|
+
if attributes.key?(:banners)
|
59
|
+
self.banners = attributes[:banners]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Checks equality by comparing each attribute.
|
64
|
+
# @param [Object] Object to be compared
|
65
|
+
def ==(other)
|
66
|
+
return true if self.equal?(other)
|
67
|
+
self.class == other.class &&
|
68
|
+
banners == other.banners
|
69
|
+
end
|
70
|
+
|
71
|
+
# @see the `==` method
|
72
|
+
# @param [Object] Object to be compared
|
73
|
+
def eql?(other)
|
74
|
+
self == other
|
75
|
+
end
|
76
|
+
|
77
|
+
# Calculates hash code according to all attributes.
|
78
|
+
# @return [Integer] Hash code
|
79
|
+
def hash
|
80
|
+
[banners].hash
|
81
|
+
end
|
82
|
+
|
83
|
+
# Builds the object from hash
|
84
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
85
|
+
# @return [Object] Returns the model itself
|
86
|
+
def self.build_from_hash(attributes)
|
87
|
+
return nil unless attributes.is_a?(Hash)
|
88
|
+
attributes = attributes.transform_keys(&:to_sym)
|
89
|
+
transformed_hash = {}
|
90
|
+
types_mapping.each_pair do |key, type|
|
91
|
+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
92
|
+
transformed_hash[key.to_sym] = nil
|
93
|
+
elsif type =~ /\AArray<(.*)>/i
|
94
|
+
# check to ensure the input is an array given that the attribute
|
95
|
+
# is documented as an array but the input is not
|
96
|
+
if attributes[attribute_map[key]].is_a?(Array)
|
97
|
+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
|
98
|
+
_deserialize(::Regexp.last_match(1), v)
|
99
|
+
}
|
100
|
+
end
|
101
|
+
elsif !attributes[attribute_map[key]].nil?
|
102
|
+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
new(transformed_hash)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Deserializes the data based on type
|
110
|
+
# @param string type Data type
|
111
|
+
# @param string value Value to be deserialized
|
112
|
+
# @return [Object] Deserialized data
|
113
|
+
def self._deserialize(type, value)
|
114
|
+
case type.to_sym
|
115
|
+
when :Time
|
116
|
+
Time.parse(value)
|
117
|
+
when :Date
|
118
|
+
Date.parse(value)
|
119
|
+
when :String
|
120
|
+
value.to_s
|
121
|
+
when :Integer
|
122
|
+
value.to_i
|
123
|
+
when :Float
|
124
|
+
value.to_f
|
125
|
+
when :Boolean
|
126
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
127
|
+
true
|
128
|
+
else
|
129
|
+
false
|
130
|
+
end
|
131
|
+
|
132
|
+
when :Object
|
133
|
+
# generic object (usually a Hash), return directly
|
134
|
+
value
|
135
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
136
|
+
inner_type = Regexp.last_match[:inner_type]
|
137
|
+
value.map { |v| _deserialize(inner_type, v) }
|
138
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
139
|
+
k_type = Regexp.last_match[:k_type]
|
140
|
+
v_type = Regexp.last_match[:v_type]
|
141
|
+
{}.tap do |hash|
|
142
|
+
value.each do |k, v|
|
143
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
# model
|
147
|
+
else
|
148
|
+
# models (e.g. Pet) or oneOf
|
149
|
+
klass = Algolia::Search.const_get(type)
|
150
|
+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
|
151
|
+
.build_from_hash(value)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
# Returns the string representation of the object
|
156
|
+
# @return [String] String presentation of the object
|
157
|
+
def to_s
|
158
|
+
to_hash.to_s
|
159
|
+
end
|
160
|
+
|
161
|
+
# to_body is an alias to to_hash (backward compatibility)
|
162
|
+
# @return [Hash] Returns the object in the form of hash
|
163
|
+
def to_body
|
164
|
+
to_hash
|
165
|
+
end
|
166
|
+
|
167
|
+
def to_json(*_args)
|
168
|
+
to_hash.to_json
|
169
|
+
end
|
170
|
+
|
171
|
+
# Returns the object in the form of hash
|
172
|
+
# @return [Hash] Returns the object in the form of hash
|
173
|
+
def to_hash
|
174
|
+
hash = {}
|
175
|
+
self.class.attribute_map.each_pair do |attr, param|
|
176
|
+
value = send(attr)
|
177
|
+
if value.nil?
|
178
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
179
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
180
|
+
end
|
181
|
+
|
182
|
+
hash[param] = _to_hash(value)
|
183
|
+
end
|
184
|
+
|
185
|
+
hash
|
186
|
+
end
|
187
|
+
|
188
|
+
# Outputs non-array value in the form of hash
|
189
|
+
# For object, use to_hash. Otherwise, just return the value
|
190
|
+
# @param [Object] value Any valid value
|
191
|
+
# @return [Hash] Returns the value in the form of hash
|
192
|
+
def _to_hash(value)
|
193
|
+
if value.is_a?(Array)
|
194
|
+
value.compact.map { |v| _to_hash(v) }
|
195
|
+
elsif value.is_a?(Hash)
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
198
|
+
end
|
199
|
+
elsif value.respond_to?(:to_hash)
|
200
|
+
value.to_hash
|
201
|
+
else
|
202
|
+
value
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
end
|
209
|
+
end
|
@@ -44,7 +44,7 @@ module Algolia
|
|
44
44
|
# Number of hits to retrieve (used in combination with `offset`).
|
45
45
|
attr_accessor :length
|
46
46
|
|
47
|
-
# Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`.
|
47
|
+
# Coordinates for the center of a circle, expressed as a comma-separated string of latitude and longitude. Only records included within a circle around this central location are included in the results. The radius of the circle is determined by the `aroundRadius` and `minimumAroundRadius` settings. This parameter is ignored if you also specify `insidePolygon` or `insideBoundingBox`.
|
48
48
|
attr_accessor :around_lat_lng
|
49
49
|
|
50
50
|
# Whether to obtain the coordinates from the request's IP address.
|
@@ -173,10 +173,10 @@ module Algolia
|
|
173
173
|
# Whether to support phrase matching and excluding words from search queries. Use the `advancedSyntaxFeatures` parameter to control which feature is supported.
|
174
174
|
attr_accessor :advanced_syntax
|
175
175
|
|
176
|
-
# Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn't include the optional words. For example, if the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words
|
176
|
+
# Words that should be considered optional when found in the query. By default, records must match all words in the search query to be included in the search results. Adding optional words can help to increase the number of search results by running an additional search query that doesn't include the optional words. For example, if the search query is \"action video\" and \"video\" is an optional word, the search engine runs two queries. One for \"action video\" and one for \"action\". Records that match all words are ranked higher. For a search query with 4 or more words **and** all its words are optional, the number of matched words required for a record to be included in the search results increases for every 1,000 records: - If `optionalWords` has less than 10 words, the required number of matched words increases by 1: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 2 matched words. - If `optionalWords` has 10 or more words, the number of required matched words increases by the number of optional words divided by 5 (rounded down). For example, with 18 optional words: results 1 to 1,000 require 1 matched word, results 1,001 to 2000 need 4 matched words. For more information, see [Optional words](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/empty-or-insufficient-results/#creating-a-list-of-optional-words).
|
177
177
|
attr_accessor :optional_words
|
178
178
|
|
179
|
-
# Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the
|
179
|
+
# Searchable attributes for which you want to [turn off the Exact ranking criterion](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/override-search-engine-defaults/in-depth/adjust-exact-settings/#turn-off-exact-for-some-attributes). Attribute names are case-sensitive. This can be useful for attributes with long values, where the likelihood of an exact match is high, such as product descriptions. Turning off the Exact ranking criterion for these attributes favors exact matching on other attributes. This reduces the impact of individual attributes with a lot of content on ranking.
|
180
180
|
attr_accessor :disable_exact_on_attributes
|
181
181
|
|
182
182
|
attr_accessor :exact_on_single_word_query
|
@@ -189,7 +189,7 @@ module Algolia
|
|
189
189
|
|
190
190
|
attr_accessor :distinct
|
191
191
|
|
192
|
-
# Whether to replace a highlighted word with the matched synonym. By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either \"home\" or \"house\" are included in the search results, and either \"home\" or \"house\" are highlighted. With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all
|
192
|
+
# Whether to replace a highlighted word with the matched synonym. By default, the original words are highlighted even if a synonym matches. For example, with `home` as a synonym for `house` and a search for `home`, records matching either \"home\" or \"house\" are included in the search results, and either \"home\" or \"house\" are highlighted. With `replaceSynonymsInHighlight` set to `true`, a search for `home` still matches the same records, but all occurrences of \"house\" are replaced by \"home\" in the highlighted response.
|
193
193
|
attr_accessor :replace_synonyms_in_highlight
|
194
194
|
|
195
195
|
# Minimum proximity score for two matching words. This adjusts the [Proximity ranking criterion](https://www.algolia.com/doc/guides/managing-results/relevance-overview/in-depth/ranking-criteria/#proximity) by equally scoring matches that are farther apart. For example, if `minProximity` is 2, neighboring matches and matches with one word between them would have the same score.
|