Skip to content

Commit c7aa2e8

Browse files
algolia-botmillotpFluf22
committed
chore: generated code for commit 197d1989. [skip ci]
algolia/api-clients-automation@197d198 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]> Co-authored-by: Thomas Raffray <[email protected]>
1 parent 0157c75 commit c7aa2e8

File tree

4 files changed

+855
-22
lines changed

4 files changed

+855
-22
lines changed

lib/algolia/api/query_suggestions_client.rb

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ def self.create_with_config(config)
3737
#
3838
# Required API Key ACLs:
3939
# - editSettings
40-
# @param query_suggestions_configuration_with_index [QuerySuggestionsConfigurationWithIndex] (required)
40+
# @param configuration_with_index [ConfigurationWithIndex] (required)
4141
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
4242
# @return [Http::Response] the response
43-
def create_config_with_http_info(query_suggestions_configuration_with_index, request_options = {})
44-
# verify the required parameter 'query_suggestions_configuration_with_index' is set
45-
if @api_client.config.client_side_validation && query_suggestions_configuration_with_index.nil?
46-
raise ArgumentError, "Parameter `query_suggestions_configuration_with_index` is required when calling `create_config`."
43+
def create_config_with_http_info(configuration_with_index, request_options = {})
44+
# verify the required parameter 'configuration_with_index' is set
45+
if @api_client.config.client_side_validation && configuration_with_index.nil?
46+
raise ArgumentError, "Parameter `configuration_with_index` is required when calling `create_config`."
4747
end
4848

4949
path = '/1/configs'
@@ -52,7 +52,7 @@ def create_config_with_http_info(query_suggestions_configuration_with_index, req
5252
header_params = {}
5353
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
5454

55-
post_body = request_options[:debug_body] || @api_client.object_to_http_body(query_suggestions_configuration_with_index)
55+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(configuration_with_index)
5656

5757
new_options = request_options.merge(
5858
:operation => :'QuerySuggestionsClient.create_config',
@@ -69,11 +69,11 @@ def create_config_with_http_info(query_suggestions_configuration_with_index, req
6969
#
7070
# Required API Key ACLs:
7171
# - editSettings
72-
# @param query_suggestions_configuration_with_index [QuerySuggestionsConfigurationWithIndex] (required)
72+
# @param configuration_with_index [ConfigurationWithIndex] (required)
7373
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
7474
# @return [BaseResponse]
75-
def create_config(query_suggestions_configuration_with_index, request_options = {})
76-
response = create_config_with_http_info(query_suggestions_configuration_with_index, request_options)
75+
def create_config(configuration_with_index, request_options = {})
76+
response = create_config_with_http_info(configuration_with_index, request_options)
7777
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'QuerySuggestions::BaseResponse')
7878
end
7979

@@ -328,10 +328,10 @@ def get_all_configs_with_http_info(request_options = {})
328328
# Required API Key ACLs:
329329
# - settings
330330
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
331-
# @return [Array<QuerySuggestionsConfigurationResponse>]
331+
# @return [Array<ConfigurationResponse>]
332332
def get_all_configs(request_options = {})
333333
response = get_all_configs_with_http_info(request_options)
334-
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'Array<QuerySuggestions::QuerySuggestionsConfigurationResponse>')
334+
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'Array<QuerySuggestions::ConfigurationResponse>')
335335
end
336336

337337
# Retrieves a single Query Suggestions configuration by its index name.
@@ -372,10 +372,10 @@ def get_config_with_http_info(index_name, request_options = {})
372372
# - settings
373373
# @param index_name [String] Query Suggestions index name. (required)
374374
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
375-
# @return [QuerySuggestionsConfigurationResponse]
375+
# @return [ConfigurationResponse]
376376
def get_config(index_name, request_options = {})
377377
response = get_config_with_http_info(index_name, request_options)
378-
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'QuerySuggestions::QuerySuggestionsConfigurationResponse')
378+
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'QuerySuggestions::ConfigurationResponse')
379379
end
380380

381381
# Reports the status of a Query Suggestions index.
@@ -471,17 +471,17 @@ def get_log_file(index_name, request_options = {})
471471
# Required API Key ACLs:
472472
# - editSettings
473473
# @param index_name [String] Query Suggestions index name. (required)
474-
# @param query_suggestions_configuration [QuerySuggestionsConfiguration] (required)
474+
# @param configuration [Configuration] (required)
475475
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
476476
# @return [Http::Response] the response
477-
def update_config_with_http_info(index_name, query_suggestions_configuration, request_options = {})
477+
def update_config_with_http_info(index_name, configuration, request_options = {})
478478
# verify the required parameter 'index_name' is set
479479
if @api_client.config.client_side_validation && index_name.nil?
480480
raise ArgumentError, "Parameter `index_name` is required when calling `update_config`."
481481
end
482-
# verify the required parameter 'query_suggestions_configuration' is set
483-
if @api_client.config.client_side_validation && query_suggestions_configuration.nil?
484-
raise ArgumentError, "Parameter `query_suggestions_configuration` is required when calling `update_config`."
482+
# verify the required parameter 'configuration' is set
483+
if @api_client.config.client_side_validation && configuration.nil?
484+
raise ArgumentError, "Parameter `configuration` is required when calling `update_config`."
485485
end
486486

487487
path = '/1/configs/{indexName}'.sub('{' + 'indexName' + '}', Transport.encode_uri(index_name.to_s))
@@ -490,7 +490,7 @@ def update_config_with_http_info(index_name, query_suggestions_configuration, re
490490
header_params = {}
491491
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
492492

493-
post_body = request_options[:debug_body] || @api_client.object_to_http_body(query_suggestions_configuration)
493+
post_body = request_options[:debug_body] || @api_client.object_to_http_body(configuration)
494494

495495
new_options = request_options.merge(
496496
:operation => :'QuerySuggestionsClient.update_config',
@@ -508,11 +508,11 @@ def update_config_with_http_info(index_name, query_suggestions_configuration, re
508508
# Required API Key ACLs:
509509
# - editSettings
510510
# @param index_name [String] Query Suggestions index name. (required)
511-
# @param query_suggestions_configuration [QuerySuggestionsConfiguration] (required)
511+
# @param configuration [Configuration] (required)
512512
# @param request_options: The request options to send along with the query, they will be merged with the transporter base parameters (headers, query params, timeouts, etc.). (optional)
513513
# @return [BaseResponse]
514-
def update_config(index_name, query_suggestions_configuration, request_options = {})
515-
response = update_config_with_http_info(index_name, query_suggestions_configuration, request_options)
514+
def update_config(index_name, configuration, request_options = {})
515+
response = update_config_with_http_info(index_name, configuration, request_options)
516516
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'QuerySuggestions::BaseResponse')
517517
end
518518
end
Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
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 Configuration
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+
# Attribute mapping from ruby-style variable name to JSON key.
24+
def self.attribute_map
25+
{
26+
:source_indices => :sourceIndices,
27+
:languages => :languages,
28+
:exclude => :exclude,
29+
:enable_personalization => :enablePersonalization,
30+
:allow_special_characters => :allowSpecialCharacters
31+
}
32+
end
33+
34+
# Returns all the JSON keys this model knows about
35+
def self.acceptable_attributes
36+
attribute_map.values
37+
end
38+
39+
# Attribute type mapping.
40+
def self.types_mapping
41+
{
42+
:source_indices => :'Array<SourceIndex>',
43+
:languages => :Languages,
44+
:exclude => :'Array<String>',
45+
:enable_personalization => :Boolean,
46+
:allow_special_characters => :Boolean
47+
}
48+
end
49+
50+
# List of attributes with nullable: true
51+
def self.openapi_nullable
52+
Set.new([
53+
:exclude
54+
])
55+
end
56+
57+
# Initializes the object
58+
# @param [Hash] attributes Model attributes in the form of hash
59+
def initialize(attributes = {})
60+
unless attributes.is_a?(Hash)
61+
raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::Configuration` initialize method"
62+
end
63+
64+
# check to see if the attribute exists and convert string to symbol for hash key
65+
attributes = attributes.each_with_object({}) do |(k, v), h|
66+
unless self.class.attribute_map.key?(k.to_sym)
67+
raise ArgumentError,
68+
"`#{k}` is not a valid attribute in `Algolia::Configuration`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
69+
end
70+
71+
h[k.to_sym] = v
72+
end
73+
74+
if attributes.key?(:source_indices)
75+
if (value = attributes[:source_indices]).is_a?(Array)
76+
self.source_indices = value
77+
end
78+
else
79+
self.source_indices = nil
80+
end
81+
82+
if attributes.key?(:languages)
83+
self.languages = attributes[:languages]
84+
end
85+
86+
if attributes.key?(:exclude)
87+
if (value = attributes[:exclude]).is_a?(Array)
88+
self.exclude = value
89+
end
90+
end
91+
92+
if attributes.key?(:enable_personalization)
93+
self.enable_personalization = attributes[:enable_personalization]
94+
end
95+
96+
if attributes.key?(:allow_special_characters)
97+
self.allow_special_characters = attributes[:allow_special_characters]
98+
end
99+
end
100+
101+
# Custom attribute writer method with validation
102+
# @param [Object] source_indices Value to be assigned
103+
def source_indices=(source_indices)
104+
if source_indices.nil?
105+
raise ArgumentError, 'source_indices cannot be nil'
106+
end
107+
108+
if source_indices.length < 1
109+
raise ArgumentError, 'invalid value for "source_indices", number of items must be greater than or equal to 1.'
110+
end
111+
112+
@source_indices = source_indices
113+
end
114+
115+
# Checks equality by comparing each attribute.
116+
# @param [Object] Object to be compared
117+
def ==(other)
118+
return true if equal?(other)
119+
120+
self.class == other.class &&
121+
source_indices == other.source_indices &&
122+
languages == other.languages &&
123+
exclude == other.exclude &&
124+
enable_personalization == other.enable_personalization &&
125+
allow_special_characters == other.allow_special_characters
126+
end
127+
128+
# @see the `==` method
129+
# @param [Object] Object to be compared
130+
def eql?(other)
131+
self == other
132+
end
133+
134+
# Calculates hash code according to all attributes.
135+
# @return [Integer] Hash code
136+
def hash
137+
[source_indices, languages, exclude, enable_personalization, allow_special_characters].hash
138+
end
139+
140+
# Builds the object from hash
141+
# @param [Hash] attributes Model attributes in the form of hash
142+
# @return [Object] Returns the model itself
143+
def self.build_from_hash(attributes)
144+
return nil unless attributes.is_a?(Hash)
145+
146+
attributes = attributes.transform_keys(&:to_sym)
147+
transformed_hash = {}
148+
types_mapping.each_pair do |key, type|
149+
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
150+
transformed_hash[key.to_sym] = nil
151+
elsif type =~ /\AArray<(.*)>/i
152+
# check to ensure the input is an array given that the attribute
153+
# is documented as an array but the input is not
154+
if attributes[attribute_map[key]].is_a?(Array)
155+
transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
156+
end
157+
elsif !attributes[attribute_map[key]].nil?
158+
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
159+
end
160+
end
161+
new(transformed_hash)
162+
end
163+
164+
# Deserializes the data based on type
165+
# @param string type Data type
166+
# @param string value Value to be deserialized
167+
# @return [Object] Deserialized data
168+
def self._deserialize(type, value)
169+
case type.to_sym
170+
when :Time
171+
Time.parse(value)
172+
when :Date
173+
Date.parse(value)
174+
when :String
175+
value.to_s
176+
when :Integer
177+
value.to_i
178+
when :Float
179+
value.to_f
180+
when :Boolean
181+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
182+
true
183+
else
184+
false
185+
end
186+
when :Object
187+
# generic object (usually a Hash), return directly
188+
value
189+
when /\AArray<(?<inner_type>.+)>\z/
190+
inner_type = Regexp.last_match[:inner_type]
191+
value.map { |v| _deserialize(inner_type, v) }
192+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
193+
k_type = Regexp.last_match[:k_type]
194+
v_type = Regexp.last_match[:v_type]
195+
{}.tap do |hash|
196+
value.each do |k, v|
197+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
198+
end
199+
end
200+
else # model
201+
# models (e.g. Pet) or oneOf
202+
klass = Algolia::QuerySuggestions.const_get(type)
203+
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204+
end
205+
end
206+
207+
# Returns the string representation of the object
208+
# @return [String] String presentation of the object
209+
def to_s
210+
to_hash.to_s
211+
end
212+
213+
# to_body is an alias to to_hash (backward compatibility)
214+
# @return [Hash] Returns the object in the form of hash
215+
def to_body
216+
to_hash
217+
end
218+
219+
def to_json(*_args)
220+
to_hash.to_json
221+
end
222+
223+
# Returns the object in the form of hash
224+
# @return [Hash] Returns the object in the form of hash
225+
def to_hash
226+
hash = {}
227+
self.class.attribute_map.each_pair do |attr, param|
228+
value = send(attr)
229+
if value.nil?
230+
is_nullable = self.class.openapi_nullable.include?(attr)
231+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232+
end
233+
234+
hash[param] = _to_hash(value)
235+
end
236+
hash
237+
end
238+
239+
# Outputs non-array value in the form of hash
240+
# For object, use to_hash. Otherwise, just return the value
241+
# @param [Object] value Any valid value
242+
# @return [Hash] Returns the value in the form of hash
243+
def _to_hash(value)
244+
if value.is_a?(Array)
245+
value.compact.map { |v| _to_hash(v) }
246+
elsif value.is_a?(Hash)
247+
{}.tap do |hash|
248+
value.each { |k, v| hash[k] = _to_hash(v) }
249+
end
250+
elsif value.respond_to? :to_hash
251+
value.to_hash
252+
else
253+
value
254+
end
255+
end
256+
end
257+
end
258+
end

0 commit comments

Comments
 (0)