Skip to content

Commit

Permalink
chore: generated code for commit 379fbc50. [skip ci]
Browse files Browse the repository at this point in the history
algolia/api-clients-automation@379fbc5

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Morgan Leroi <[email protected]>
Co-authored-by: shortcuts <[email protected]>
  • Loading branch information
3 people committed Jan 23, 2024
1 parent b77379a commit 30a0d97
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 19 deletions.
18 changes: 3 additions & 15 deletions lib/algolia/api/search_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2493,26 +2493,17 @@ def search_single_index(index_name, search_params = nil, request_options = {})
# Search for synonyms.
# Search for synonyms in your index. You can control and filter the search with parameters. To get all synonyms, send an empty request body.
# @param index_name [String] Index on which to perform the request. (required)
# @param type [SynonymType] Search for specific [types of synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#the-different-types-of-synonyms).
# @param page [Integer] Returns the requested page number (the first page is 0). Page size is set by &#x60;hitsPerPage&#x60;. When null, there&#39;s no pagination. (default to 0)
# @param hits_per_page [Integer] Maximum number of hits per page. (default to 100)
# @param search_synonyms_params [SearchSynonymsParams] Body of the &#x60;searchSynonyms&#x60; operation.
# @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)
# @return [Http::Response] the response
def search_synonyms_with_http_info(index_name, type = nil, page = nil, hits_per_page = nil, search_synonyms_params = nil, request_options = {})
def search_synonyms_with_http_info(index_name, search_synonyms_params = nil, request_options = {})
# verify the required parameter 'index_name' is set
if @api_client.config.client_side_validation && index_name.nil?
raise ArgumentError, "Parameter `index_name` is required when calling `search_synonyms`."
end
if @api_client.config.client_side_validation && !page.nil? && page < 0
raise ArgumentError, 'invalid value for ""page"" when calling SearchClient.search_synonyms, must be greater than or equal to 0.'
end

path = '/1/indexes/{indexName}/synonyms/search'.sub('{' + 'indexName' + '}', @api_client.encode_uri(index_name.to_s))
query_params = {}
query_params[:type] = type unless type.nil?
query_params[:page] = page unless page.nil?
query_params[:hitsPerPage] = hits_per_page unless hits_per_page.nil?
query_params = query_params.merge(request_options[:query_params]) unless request_options[:query_params].nil?
header_params = {}
header_params = header_params.merge(request_options[:header_params]) unless request_options[:header_params].nil?
Expand All @@ -2533,14 +2524,11 @@ def search_synonyms_with_http_info(index_name, type = nil, page = nil, hits_per_
# Search for synonyms.
# Search for synonyms in your index. You can control and filter the search with parameters. To get all synonyms, send an empty request body.
# @param index_name [String] Index on which to perform the request. (required)
# @param type [SynonymType] Search for specific [types of synonyms](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/adding-synonyms/#the-different-types-of-synonyms).
# @param page [Integer] Returns the requested page number (the first page is 0). Page size is set by &#x60;hitsPerPage&#x60;. When null, there&#39;s no pagination. (default to 0)
# @param hits_per_page [Integer] Maximum number of hits per page. (default to 100)
# @param search_synonyms_params [SearchSynonymsParams] Body of the &#x60;searchSynonyms&#x60; operation.
# @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)
# @return [SearchSynonymsResponse]
def search_synonyms(index_name, type = nil, page = nil, hits_per_page = nil, search_synonyms_params = nil, request_options = {})
response = search_synonyms_with_http_info(index_name, type, page, hits_per_page, search_synonyms_params, request_options)
def search_synonyms(index_name, search_synonyms_params = nil, request_options = {})
response = search_synonyms_with_http_info(index_name, search_synonyms_params, request_options)
@api_client.deserialize(response.body, request_options[:debug_return_type] || 'Search::SearchSynonymsResponse')
end

Expand Down
77 changes: 73 additions & 4 deletions lib/algolia/models/search/search_synonyms_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,43 @@ class SearchSynonymsParams
# Text to search for in an index.
attr_accessor :query

attr_accessor :type

# Page to retrieve (the first page is `0`, not `1`).
attr_accessor :page

# Number of hits per page.
attr_accessor :hits_per_page

class EnumAttributeValidator
attr_reader :datatype
attr_reader :allowable_values

def initialize(datatype, allowable_values)
@allowable_values = allowable_values.map do |value|
case datatype.to_s
when /Integer/i
value.to_i
when /Float/i
value.to_f
else
value
end
end
end

def valid?(value)
!value || allowable_values.include?(value)
end
end

# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:query => :query
:query => :query,
:type => :type,
:page => :page,
:hits_per_page => :hitsPerPage
}
end

Expand All @@ -24,7 +57,10 @@ def self.acceptable_attributes
# Attribute type mapping.
def self.types_mapping
{
:query => :String
:query => :String,
:type => :SynonymType,
:page => :Integer,
:hits_per_page => :Integer
}
end

Expand Down Expand Up @@ -53,6 +89,36 @@ def initialize(attributes = {})
if attributes.key?(:query)
self.query = attributes[:query]
end

if attributes.key?(:type)
self.type = attributes[:type]
end

if attributes.key?(:page)
self.page = attributes[:page]
end

if attributes.key?(:hits_per_page)
self.hits_per_page = attributes[:hits_per_page]
end
end

# Custom attribute writer method with validation
# @param [Object] hits_per_page Value to be assigned
def hits_per_page=(hits_per_page)
if hits_per_page.nil?
raise ArgumentError, 'hits_per_page cannot be nil'
end

if hits_per_page > 1000
raise ArgumentError, 'invalid value for "hits_per_page", must be smaller than or equal to 1000.'
end

if hits_per_page < 1
raise ArgumentError, 'invalid value for "hits_per_page", must be greater than or equal to 1.'
end

@hits_per_page = hits_per_page
end

# Checks equality by comparing each attribute.
Expand All @@ -61,7 +127,10 @@ def ==(other)
return true if equal?(other)

self.class == other.class &&
query == other.query
query == other.query &&
type == other.type &&
page == other.page &&
hits_per_page == other.hits_per_page
end

# @see the `==` method
Expand All @@ -73,7 +142,7 @@ def eql?(other)
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
[query].hash
[query, type, page, hits_per_page].hash
end

# Builds the object from hash
Expand Down

0 comments on commit 30a0d97

Please sign in to comment.