algolia 3.0.0.beta.6 → 3.0.0.beta.8

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.
@@ -0,0 +1,298 @@
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 QuerySuggestions
8
+ # API response for retrieving Query Suggestions configurations.
9
+ class ConfigurationResponse
10
+ # Algolia application ID to which this Query Suggestions configuration belongs.
11
+ attr_accessor :app_id
12
+
13
+ # Name of the Query Suggestions index (case-sensitive).
14
+ attr_accessor :index_name
15
+
16
+ # Algolia indices from which to get the popular searches for query suggestions.
17
+ attr_accessor :source_indices
18
+
19
+ attr_accessor :languages
20
+
21
+ attr_accessor :exclude
22
+
23
+ # Whether to turn on personalized query suggestions.
24
+ attr_accessor :enable_personalization
25
+
26
+ # Whether to include suggestions with special characters.
27
+ attr_accessor :allow_special_characters
28
+
29
+ # Attribute mapping from ruby-style variable name to JSON key.
30
+ def self.attribute_map
31
+ {
32
+ :app_id => :appID,
33
+ :index_name => :indexName,
34
+ :source_indices => :sourceIndices,
35
+ :languages => :languages,
36
+ :exclude => :exclude,
37
+ :enable_personalization => :enablePersonalization,
38
+ :allow_special_characters => :allowSpecialCharacters
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.types_mapping
49
+ {
50
+ :app_id => :String,
51
+ :index_name => :String,
52
+ :source_indices => :'Array<SourceIndex>',
53
+ :languages => :Languages,
54
+ :exclude => :'Array<String>',
55
+ :enable_personalization => :Boolean,
56
+ :allow_special_characters => :Boolean
57
+ }
58
+ end
59
+
60
+ # List of attributes with nullable: true
61
+ def self.openapi_nullable
62
+ Set.new([
63
+ :exclude
64
+ ])
65
+ end
66
+
67
+ # List of class defined in allOf (OpenAPI v3)
68
+ def self.openapi_all_of
69
+ [
70
+ :AppID,
71
+ :ConfigurationWithIndex
72
+ ]
73
+ end
74
+
75
+ # Initializes the object
76
+ # @param [Hash] attributes Model attributes in the form of hash
77
+ def initialize(attributes = {})
78
+ unless attributes.is_a?(Hash)
79
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ConfigurationResponse` initialize method"
80
+ end
81
+
82
+ # check to see if the attribute exists and convert string to symbol for hash key
83
+ attributes = attributes.each_with_object({}) do |(k, v), h|
84
+ unless self.class.attribute_map.key?(k.to_sym)
85
+ raise ArgumentError,
86
+ "`#{k}` is not a valid attribute in `Algolia::ConfigurationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
87
+ end
88
+
89
+ h[k.to_sym] = v
90
+ end
91
+
92
+ if attributes.key?(:app_id)
93
+ self.app_id = attributes[:app_id]
94
+ else
95
+ self.app_id = nil
96
+ end
97
+
98
+ if attributes.key?(:index_name)
99
+ self.index_name = attributes[:index_name]
100
+ else
101
+ self.index_name = nil
102
+ end
103
+
104
+ if attributes.key?(:source_indices)
105
+ if (value = attributes[:source_indices]).is_a?(Array)
106
+ self.source_indices = value
107
+ end
108
+ else
109
+ self.source_indices = nil
110
+ end
111
+
112
+ if attributes.key?(:languages)
113
+ self.languages = attributes[:languages]
114
+ else
115
+ self.languages = nil
116
+ end
117
+
118
+ if attributes.key?(:exclude)
119
+ if (value = attributes[:exclude]).is_a?(Array)
120
+ self.exclude = value
121
+ end
122
+ else
123
+ self.exclude = nil
124
+ end
125
+
126
+ if attributes.key?(:enable_personalization)
127
+ self.enable_personalization = attributes[:enable_personalization]
128
+ else
129
+ self.enable_personalization = nil
130
+ end
131
+
132
+ if attributes.key?(:allow_special_characters)
133
+ self.allow_special_characters = attributes[:allow_special_characters]
134
+ else
135
+ self.allow_special_characters = nil
136
+ end
137
+ end
138
+
139
+ # Custom attribute writer method with validation
140
+ # @param [Object] source_indices Value to be assigned
141
+ def source_indices=(source_indices)
142
+ if source_indices.nil?
143
+ raise ArgumentError, 'source_indices cannot be nil'
144
+ end
145
+
146
+ if source_indices.length < 1
147
+ raise ArgumentError, 'invalid value for "source_indices", number of items must be greater than or equal to 1.'
148
+ end
149
+
150
+ @source_indices = source_indices
151
+ end
152
+
153
+ # Checks equality by comparing each attribute.
154
+ # @param [Object] Object to be compared
155
+ def ==(other)
156
+ return true if equal?(other)
157
+
158
+ self.class == other.class &&
159
+ app_id == other.app_id &&
160
+ index_name == other.index_name &&
161
+ source_indices == other.source_indices &&
162
+ languages == other.languages &&
163
+ exclude == other.exclude &&
164
+ enable_personalization == other.enable_personalization &&
165
+ allow_special_characters == other.allow_special_characters
166
+ end
167
+
168
+ # @see the `==` method
169
+ # @param [Object] Object to be compared
170
+ def eql?(other)
171
+ self == other
172
+ end
173
+
174
+ # Calculates hash code according to all attributes.
175
+ # @return [Integer] Hash code
176
+ def hash
177
+ [app_id, index_name, source_indices, languages, exclude, enable_personalization, allow_special_characters].hash
178
+ end
179
+
180
+ # Builds the object from hash
181
+ # @param [Hash] attributes Model attributes in the form of hash
182
+ # @return [Object] Returns the model itself
183
+ def self.build_from_hash(attributes)
184
+ return nil unless attributes.is_a?(Hash)
185
+
186
+ attributes = attributes.transform_keys(&:to_sym)
187
+ transformed_hash = {}
188
+ types_mapping.each_pair do |key, type|
189
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
190
+ transformed_hash[key.to_sym] = nil
191
+ elsif type =~ /\AArray<(.*)>/i
192
+ # check to ensure the input is an array given that the attribute
193
+ # is documented as an array but the input is not
194
+ if attributes[attribute_map[key]].is_a?(Array)
195
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
196
+ end
197
+ elsif !attributes[attribute_map[key]].nil?
198
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
199
+ end
200
+ end
201
+ new(transformed_hash)
202
+ end
203
+
204
+ # Deserializes the data based on type
205
+ # @param string type Data type
206
+ # @param string value Value to be deserialized
207
+ # @return [Object] Deserialized data
208
+ def self._deserialize(type, value)
209
+ case type.to_sym
210
+ when :Time
211
+ Time.parse(value)
212
+ when :Date
213
+ Date.parse(value)
214
+ when :String
215
+ value.to_s
216
+ when :Integer
217
+ value.to_i
218
+ when :Float
219
+ value.to_f
220
+ when :Boolean
221
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
222
+ true
223
+ else
224
+ false
225
+ end
226
+ when :Object
227
+ # generic object (usually a Hash), return directly
228
+ value
229
+ when /\AArray<(?<inner_type>.+)>\z/
230
+ inner_type = Regexp.last_match[:inner_type]
231
+ value.map { |v| _deserialize(inner_type, v) }
232
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
233
+ k_type = Regexp.last_match[:k_type]
234
+ v_type = Regexp.last_match[:v_type]
235
+ {}.tap do |hash|
236
+ value.each do |k, v|
237
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
238
+ end
239
+ end
240
+ else # model
241
+ # models (e.g. Pet) or oneOf
242
+ klass = Algolia::QuerySuggestions.const_get(type)
243
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
244
+ end
245
+ end
246
+
247
+ # Returns the string representation of the object
248
+ # @return [String] String presentation of the object
249
+ def to_s
250
+ to_hash.to_s
251
+ end
252
+
253
+ # to_body is an alias to to_hash (backward compatibility)
254
+ # @return [Hash] Returns the object in the form of hash
255
+ def to_body
256
+ to_hash
257
+ end
258
+
259
+ def to_json(*_args)
260
+ to_hash.to_json
261
+ end
262
+
263
+ # Returns the object in the form of hash
264
+ # @return [Hash] Returns the object in the form of hash
265
+ def to_hash
266
+ hash = {}
267
+ self.class.attribute_map.each_pair do |attr, param|
268
+ value = send(attr)
269
+ if value.nil?
270
+ is_nullable = self.class.openapi_nullable.include?(attr)
271
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
272
+ end
273
+
274
+ hash[param] = _to_hash(value)
275
+ end
276
+ hash
277
+ end
278
+
279
+ # Outputs non-array value in the form of hash
280
+ # For object, use to_hash. Otherwise, just return the value
281
+ # @param [Object] value Any valid value
282
+ # @return [Hash] Returns the value in the form of hash
283
+ def _to_hash(value)
284
+ if value.is_a?(Array)
285
+ value.compact.map { |v| _to_hash(v) }
286
+ elsif value.is_a?(Hash)
287
+ {}.tap do |hash|
288
+ value.each { |k, v| hash[k] = _to_hash(v) }
289
+ end
290
+ elsif value.respond_to? :to_hash
291
+ value.to_hash
292
+ else
293
+ value
294
+ end
295
+ end
296
+ end
297
+ end
298
+ end
@@ -0,0 +1,277 @@
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 QuerySuggestions
8
+ # Query Suggestions configuration.
9
+ class ConfigurationWithIndex
10
+ # Algolia indices from which to get the popular searches for query suggestions.
11
+ attr_accessor :source_indices
12
+
13
+ attr_accessor :languages
14
+
15
+ attr_accessor :exclude
16
+
17
+ # Whether to turn on personalized query suggestions.
18
+ attr_accessor :enable_personalization
19
+
20
+ # Whether to include suggestions with special characters.
21
+ attr_accessor :allow_special_characters
22
+
23
+ # Name of the Query Suggestions index (case-sensitive).
24
+ attr_accessor :index_name
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :source_indices => :sourceIndices,
30
+ :languages => :languages,
31
+ :exclude => :exclude,
32
+ :enable_personalization => :enablePersonalization,
33
+ :allow_special_characters => :allowSpecialCharacters,
34
+ :index_name => :indexName
35
+ }
36
+ end
37
+
38
+ # Returns all the JSON keys this model knows about
39
+ def self.acceptable_attributes
40
+ attribute_map.values
41
+ end
42
+
43
+ # Attribute type mapping.
44
+ def self.types_mapping
45
+ {
46
+ :source_indices => :'Array<SourceIndex>',
47
+ :languages => :Languages,
48
+ :exclude => :'Array<String>',
49
+ :enable_personalization => :Boolean,
50
+ :allow_special_characters => :Boolean,
51
+ :index_name => :String
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ :exclude
59
+ ])
60
+ end
61
+
62
+ # List of class defined in allOf (OpenAPI v3)
63
+ def self.openapi_all_of
64
+ [
65
+ :Configuration
66
+ ]
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ unless attributes.is_a?(Hash)
73
+ raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::ConfigurationWithIndex` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) do |(k, v), h|
78
+ unless self.class.attribute_map.key?(k.to_sym)
79
+ raise ArgumentError,
80
+ "`#{k}` is not a valid attribute in `Algolia::ConfigurationWithIndex`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+
83
+ h[k.to_sym] = v
84
+ end
85
+
86
+ if attributes.key?(:source_indices)
87
+ if (value = attributes[:source_indices]).is_a?(Array)
88
+ self.source_indices = value
89
+ end
90
+ else
91
+ self.source_indices = nil
92
+ end
93
+
94
+ if attributes.key?(:languages)
95
+ self.languages = attributes[:languages]
96
+ end
97
+
98
+ if attributes.key?(:exclude)
99
+ if (value = attributes[:exclude]).is_a?(Array)
100
+ self.exclude = value
101
+ end
102
+ end
103
+
104
+ if attributes.key?(:enable_personalization)
105
+ self.enable_personalization = attributes[:enable_personalization]
106
+ end
107
+
108
+ if attributes.key?(:allow_special_characters)
109
+ self.allow_special_characters = attributes[:allow_special_characters]
110
+ end
111
+
112
+ if attributes.key?(:index_name)
113
+ self.index_name = attributes[:index_name]
114
+ else
115
+ self.index_name = nil
116
+ end
117
+ end
118
+
119
+ # Custom attribute writer method with validation
120
+ # @param [Object] source_indices Value to be assigned
121
+ def source_indices=(source_indices)
122
+ if source_indices.nil?
123
+ raise ArgumentError, 'source_indices cannot be nil'
124
+ end
125
+
126
+ if source_indices.length < 1
127
+ raise ArgumentError, 'invalid value for "source_indices", number of items must be greater than or equal to 1.'
128
+ end
129
+
130
+ @source_indices = source_indices
131
+ end
132
+
133
+ # Checks equality by comparing each attribute.
134
+ # @param [Object] Object to be compared
135
+ def ==(other)
136
+ return true if equal?(other)
137
+
138
+ self.class == other.class &&
139
+ source_indices == other.source_indices &&
140
+ languages == other.languages &&
141
+ exclude == other.exclude &&
142
+ enable_personalization == other.enable_personalization &&
143
+ allow_special_characters == other.allow_special_characters &&
144
+ index_name == other.index_name
145
+ end
146
+
147
+ # @see the `==` method
148
+ # @param [Object] Object to be compared
149
+ def eql?(other)
150
+ self == other
151
+ end
152
+
153
+ # Calculates hash code according to all attributes.
154
+ # @return [Integer] Hash code
155
+ def hash
156
+ [source_indices, languages, exclude, enable_personalization, allow_special_characters, index_name].hash
157
+ end
158
+
159
+ # Builds the object from hash
160
+ # @param [Hash] attributes Model attributes in the form of hash
161
+ # @return [Object] Returns the model itself
162
+ def self.build_from_hash(attributes)
163
+ return nil unless attributes.is_a?(Hash)
164
+
165
+ attributes = attributes.transform_keys(&:to_sym)
166
+ transformed_hash = {}
167
+ types_mapping.each_pair do |key, type|
168
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
169
+ transformed_hash[key.to_sym] = nil
170
+ elsif type =~ /\AArray<(.*)>/i
171
+ # check to ensure the input is an array given that the attribute
172
+ # is documented as an array but the input is not
173
+ if attributes[attribute_map[key]].is_a?(Array)
174
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
175
+ end
176
+ elsif !attributes[attribute_map[key]].nil?
177
+ transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
178
+ end
179
+ end
180
+ new(transformed_hash)
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def self._deserialize(type, value)
188
+ case type.to_sym
189
+ when :Time
190
+ Time.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :String
194
+ value.to_s
195
+ when :Integer
196
+ value.to_i
197
+ when :Float
198
+ value.to_f
199
+ when :Boolean
200
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
201
+ true
202
+ else
203
+ false
204
+ end
205
+ when :Object
206
+ # generic object (usually a Hash), return directly
207
+ value
208
+ when /\AArray<(?<inner_type>.+)>\z/
209
+ inner_type = Regexp.last_match[:inner_type]
210
+ value.map { |v| _deserialize(inner_type, v) }
211
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
212
+ k_type = Regexp.last_match[:k_type]
213
+ v_type = Regexp.last_match[:v_type]
214
+ {}.tap do |hash|
215
+ value.each do |k, v|
216
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
217
+ end
218
+ end
219
+ else # model
220
+ # models (e.g. Pet) or oneOf
221
+ klass = Algolia::QuerySuggestions.const_get(type)
222
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ def to_json(*_args)
239
+ to_hash.to_json
240
+ end
241
+
242
+ # Returns the object in the form of hash
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_hash
245
+ hash = {}
246
+ self.class.attribute_map.each_pair do |attr, param|
247
+ value = send(attr)
248
+ if value.nil?
249
+ is_nullable = self.class.openapi_nullable.include?(attr)
250
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
251
+ end
252
+
253
+ hash[param] = _to_hash(value)
254
+ end
255
+ hash
256
+ end
257
+
258
+ # Outputs non-array value in the form of hash
259
+ # For object, use to_hash. Otherwise, just return the value
260
+ # @param [Object] value Any valid value
261
+ # @return [Hash] Returns the value in the form of hash
262
+ def _to_hash(value)
263
+ if value.is_a?(Array)
264
+ value.compact.map { |v| _to_hash(v) }
265
+ elsif value.is_a?(Hash)
266
+ {}.tap do |hash|
267
+ value.each { |k, v| hash[k] = _to_hash(v) }
268
+ end
269
+ elsif value.respond_to? :to_hash
270
+ value.to_hash
271
+ else
272
+ value
273
+ end
274
+ end
275
+ end
276
+ end
277
+ end
@@ -5,7 +5,7 @@ require 'time'
5
5
 
6
6
  module Algolia
7
7
  module Recommend
8
- # [Redirect results to a URL](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/redirects/).
8
+ # [Redirect results to a URL](https://www.algolia.com/doc/guides/managing-results/rules/merchandising-and-promoting/how-to/redirects/), this this parameter is for internal use only.
9
9
  class Redirect
10
10
  attr_accessor :index
11
11