algolia 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +1 -1
  4. data/lib/algolia/api/analytics_client.rb +144 -32
  5. data/lib/algolia/api/search_client.rb +16 -16
  6. data/lib/algolia/models/recommend/banner.rb +218 -0
  7. data/lib/algolia/models/recommend/banner_image.rb +221 -0
  8. data/lib/algolia/models/recommend/banner_image_url.rb +212 -0
  9. data/lib/algolia/models/recommend/banner_link.rb +212 -0
  10. data/lib/algolia/models/recommend/banners.rb +209 -0
  11. data/lib/algolia/models/recommend/fallback_params.rb +8 -8
  12. data/lib/algolia/models/recommend/numeric_filters.rb +1 -1
  13. data/lib/algolia/models/recommend/recommend_search_params.rb +8 -8
  14. data/lib/algolia/models/recommend/rendering_content.rb +14 -5
  15. data/lib/algolia/models/recommend/typo_tolerance.rb +1 -1
  16. data/lib/algolia/models/recommend/widgets.rb +209 -0
  17. data/lib/algolia/models/search/api_key.rb +1 -1
  18. data/lib/algolia/models/search/banner.rb +218 -0
  19. data/lib/algolia/models/search/banner_image.rb +221 -0
  20. data/lib/algolia/models/search/banner_image_url.rb +212 -0
  21. data/lib/algolia/models/search/banner_link.rb +212 -0
  22. data/lib/algolia/models/search/banners.rb +209 -0
  23. data/lib/algolia/models/search/browse_params_object.rb +4 -4
  24. data/lib/algolia/models/search/consequence_params.rb +4 -4
  25. data/lib/algolia/models/search/delete_by_params.rb +1 -1
  26. data/lib/algolia/models/search/get_api_key_response.rb +1 -1
  27. data/lib/algolia/models/search/index_settings.rb +7 -7
  28. data/lib/algolia/models/search/numeric_filters.rb +1 -1
  29. data/lib/algolia/models/search/rendering_content.rb +14 -5
  30. data/lib/algolia/models/search/search_for_facets.rb +4 -4
  31. data/lib/algolia/models/search/search_for_hits.rb +4 -4
  32. data/lib/algolia/models/search/search_params_object.rb +4 -4
  33. data/lib/algolia/models/search/settings_response.rb +7 -7
  34. data/lib/algolia/models/search/typo_tolerance.rb +1 -1
  35. data/lib/algolia/models/search/widgets.rb +209 -0
  36. data/lib/algolia/version.rb +1 -1
  37. metadata +14 -2
@@ -0,0 +1,218 @@
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 Recommend
8
+ # a search banner with image and url.
9
+ class Banner
10
+ attr_accessor :image
11
+
12
+ attr_accessor :link
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :image => :image,
18
+ :link => :link
19
+ }
20
+ end
21
+
22
+ # Returns all the JSON keys this model knows about
23
+ def self.acceptable_attributes
24
+ attribute_map.values
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.types_mapping
29
+ {
30
+ :image => :"BannerImage",
31
+ :link => :"BannerLink"
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new(
38
+ []
39
+ )
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ if (!attributes.is_a?(Hash))
46
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Banner` initialize method"
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::Banner`. 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?(:image)
63
+ self.image = attributes[:image]
64
+ end
65
+
66
+ if attributes.key?(:link)
67
+ self.link = attributes[:link]
68
+ end
69
+ end
70
+
71
+ # Checks equality by comparing each attribute.
72
+ # @param [Object] Object to be compared
73
+ def ==(other)
74
+ return true if self.equal?(other)
75
+ self.class == other.class &&
76
+ image == other.image &&
77
+ link == other.link
78
+ end
79
+
80
+ # @see the `==` method
81
+ # @param [Object] Object to be compared
82
+ def eql?(other)
83
+ self == other
84
+ end
85
+
86
+ # Calculates hash code according to all attributes.
87
+ # @return [Integer] Hash code
88
+ def hash
89
+ [image, link].hash
90
+ end
91
+
92
+ # Builds the object from hash
93
+ # @param [Hash] attributes Model attributes in the form of hash
94
+ # @return [Object] Returns the model itself
95
+ def self.build_from_hash(attributes)
96
+ return nil unless attributes.is_a?(Hash)
97
+ attributes = attributes.transform_keys(&:to_sym)
98
+ transformed_hash = {}
99
+ types_mapping.each_pair do |key, type|
100
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
101
+ transformed_hash[key.to_sym] = nil
102
+ elsif type =~ /\AArray<(.*)>/i
103
+ # check to ensure the input is an array given that the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[attribute_map[key]].is_a?(Array)
106
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
107
+ _deserialize(::Regexp.last_match(1), v)
108
+ }
109
+ end
110
+ elsif !attributes[attribute_map[key]].nil?
111
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
112
+ end
113
+ end
114
+
115
+ new(transformed_hash)
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def self._deserialize(type, value)
123
+ case type.to_sym
124
+ when :Time
125
+ Time.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :Boolean
135
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+
141
+ when :Object
142
+ # generic object (usually a Hash), return directly
143
+ value
144
+ when /\AArray<(?<inner_type>.+)>\z/
145
+ inner_type = Regexp.last_match[:inner_type]
146
+ value.map { |v| _deserialize(inner_type, v) }
147
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
148
+ k_type = Regexp.last_match[:k_type]
149
+ v_type = Regexp.last_match[:v_type]
150
+ {}.tap do |hash|
151
+ value.each do |k, v|
152
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
153
+ end
154
+ end
155
+ # model
156
+ else
157
+ # models (e.g. Pet) or oneOf
158
+ klass = Algolia::Recommend.const_get(type)
159
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
160
+ .build_from_hash(value)
161
+ end
162
+ end
163
+
164
+ # Returns the string representation of the object
165
+ # @return [String] String presentation of the object
166
+ def to_s
167
+ to_hash.to_s
168
+ end
169
+
170
+ # to_body is an alias to to_hash (backward compatibility)
171
+ # @return [Hash] Returns the object in the form of hash
172
+ def to_body
173
+ to_hash
174
+ end
175
+
176
+ def to_json(*_args)
177
+ to_hash.to_json
178
+ end
179
+
180
+ # Returns the object in the form of hash
181
+ # @return [Hash] Returns the object in the form of hash
182
+ def to_hash
183
+ hash = {}
184
+ self.class.attribute_map.each_pair do |attr, param|
185
+ value = send(attr)
186
+ if value.nil?
187
+ is_nullable = self.class.openapi_nullable.include?(attr)
188
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
189
+ end
190
+
191
+ hash[param] = _to_hash(value)
192
+ end
193
+
194
+ hash
195
+ end
196
+
197
+ # Outputs non-array value in the form of hash
198
+ # For object, use to_hash. Otherwise, just return the value
199
+ # @param [Object] value Any valid value
200
+ # @return [Hash] Returns the value in the form of hash
201
+ def _to_hash(value)
202
+ if value.is_a?(Array)
203
+ value.compact.map { |v| _to_hash(v) }
204
+ elsif value.is_a?(Hash)
205
+ {}.tap do |hash|
206
+ value.each { |k, v| hash[k] = _to_hash(v) }
207
+ end
208
+ elsif value.respond_to?(:to_hash)
209
+ value.to_hash
210
+ else
211
+ value
212
+ end
213
+ end
214
+
215
+ end
216
+
217
+ end
218
+ end
@@ -0,0 +1,221 @@
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 Recommend
8
+ # image of a search banner.
9
+ class BannerImage
10
+ attr_accessor :urls
11
+
12
+ attr_accessor :title
13
+
14
+ # Attribute mapping from ruby-style variable name to JSON key.
15
+ def self.attribute_map
16
+ {
17
+ :urls => :urls,
18
+ :title => :title
19
+ }
20
+ end
21
+
22
+ # Returns all the JSON keys this model knows about
23
+ def self.acceptable_attributes
24
+ attribute_map.values
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.types_mapping
29
+ {
30
+ :urls => :"BannerImageUrl",
31
+ :title => :"String"
32
+ }
33
+ end
34
+
35
+ # List of attributes with nullable: true
36
+ def self.openapi_nullable
37
+ Set.new(
38
+ []
39
+ )
40
+ end
41
+
42
+ # Initializes the object
43
+ # @param [Hash] attributes Model attributes in the form of hash
44
+ def initialize(attributes = {})
45
+ if (!attributes.is_a?(Hash))
46
+ raise(
47
+ ArgumentError,
48
+ "The input argument (attributes) must be a hash in `Algolia::BannerImage` initialize method"
49
+ )
50
+ end
51
+
52
+ # check to see if the attribute exists and convert string to symbol for hash key
53
+ attributes = attributes.each_with_object({}) { |(k, v), h|
54
+ if (!self.class.attribute_map.key?(k.to_sym))
55
+ raise(
56
+ ArgumentError,
57
+ "`#{k}` is not a valid attribute in `Algolia::BannerImage`. Please check the name to make sure it's valid. List of attributes: " +
58
+ self.class.attribute_map.keys.inspect
59
+ )
60
+ end
61
+
62
+ h[k.to_sym] = v
63
+ }
64
+
65
+ if attributes.key?(:urls)
66
+ self.urls = attributes[:urls]
67
+ end
68
+
69
+ if attributes.key?(:title)
70
+ self.title = attributes[:title]
71
+ end
72
+ end
73
+
74
+ # Checks equality by comparing each attribute.
75
+ # @param [Object] Object to be compared
76
+ def ==(other)
77
+ return true if self.equal?(other)
78
+ self.class == other.class &&
79
+ urls == other.urls &&
80
+ title == other.title
81
+ end
82
+
83
+ # @see the `==` method
84
+ # @param [Object] Object to be compared
85
+ def eql?(other)
86
+ self == other
87
+ end
88
+
89
+ # Calculates hash code according to all attributes.
90
+ # @return [Integer] Hash code
91
+ def hash
92
+ [urls, title].hash
93
+ end
94
+
95
+ # Builds the object from hash
96
+ # @param [Hash] attributes Model attributes in the form of hash
97
+ # @return [Object] Returns the model itself
98
+ def self.build_from_hash(attributes)
99
+ return nil unless attributes.is_a?(Hash)
100
+ attributes = attributes.transform_keys(&:to_sym)
101
+ transformed_hash = {}
102
+ types_mapping.each_pair do |key, type|
103
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
104
+ transformed_hash[key.to_sym] = nil
105
+ elsif type =~ /\AArray<(.*)>/i
106
+ # check to ensure the input is an array given that the attribute
107
+ # is documented as an array but the input is not
108
+ if attributes[attribute_map[key]].is_a?(Array)
109
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
110
+ _deserialize(::Regexp.last_match(1), v)
111
+ }
112
+ end
113
+ elsif !attributes[attribute_map[key]].nil?
114
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
115
+ end
116
+ end
117
+
118
+ new(transformed_hash)
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def self._deserialize(type, value)
126
+ case type.to_sym
127
+ when :Time
128
+ Time.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :Boolean
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+
144
+ when :Object
145
+ # generic object (usually a Hash), return directly
146
+ value
147
+ when /\AArray<(?<inner_type>.+)>\z/
148
+ inner_type = Regexp.last_match[:inner_type]
149
+ value.map { |v| _deserialize(inner_type, v) }
150
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
151
+ k_type = Regexp.last_match[:k_type]
152
+ v_type = Regexp.last_match[:v_type]
153
+ {}.tap do |hash|
154
+ value.each do |k, v|
155
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
156
+ end
157
+ end
158
+ # model
159
+ else
160
+ # models (e.g. Pet) or oneOf
161
+ klass = Algolia::Recommend.const_get(type)
162
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
163
+ .build_from_hash(value)
164
+ end
165
+ end
166
+
167
+ # Returns the string representation of the object
168
+ # @return [String] String presentation of the object
169
+ def to_s
170
+ to_hash.to_s
171
+ end
172
+
173
+ # to_body is an alias to to_hash (backward compatibility)
174
+ # @return [Hash] Returns the object in the form of hash
175
+ def to_body
176
+ to_hash
177
+ end
178
+
179
+ def to_json(*_args)
180
+ to_hash.to_json
181
+ end
182
+
183
+ # Returns the object in the form of hash
184
+ # @return [Hash] Returns the object in the form of hash
185
+ def to_hash
186
+ hash = {}
187
+ self.class.attribute_map.each_pair do |attr, param|
188
+ value = send(attr)
189
+ if value.nil?
190
+ is_nullable = self.class.openapi_nullable.include?(attr)
191
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
192
+ end
193
+
194
+ hash[param] = _to_hash(value)
195
+ end
196
+
197
+ hash
198
+ end
199
+
200
+ # Outputs non-array value in the form of hash
201
+ # For object, use to_hash. Otherwise, just return the value
202
+ # @param [Object] value Any valid value
203
+ # @return [Hash] Returns the value in the form of hash
204
+ def _to_hash(value)
205
+ if value.is_a?(Array)
206
+ value.compact.map { |v| _to_hash(v) }
207
+ elsif value.is_a?(Hash)
208
+ {}.tap do |hash|
209
+ value.each { |k, v| hash[k] = _to_hash(v) }
210
+ end
211
+ elsif value.respond_to?(:to_hash)
212
+ value.to_hash
213
+ else
214
+ value
215
+ end
216
+ end
217
+
218
+ end
219
+
220
+ end
221
+ 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 Recommend
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::Recommend.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