lib/algolia/models/recommend/fallback_params.rb in algolia-3.0.0.beta.8 vs lib/algolia/models/recommend/fallback_params.rb in algolia-3.0.0.beta.9
- old
+ new
@@ -1,9 +1,9 @@
# 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.
-require 'date'
-require 'time'
+require "date"
+require "time"
module Algolia
module Recommend
class FallbackParams
# Search query.
@@ -327,119 +327,125 @@
end
# Attribute type mapping.
def self.types_mapping
{
- :query => :String,
- :similar_query => :String,
- :filters => :String,
- :facet_filters => :FacetFilters,
- :optional_filters => :OptionalFilters,
- :numeric_filters => :NumericFilters,
- :tag_filters => :TagFilters,
- :sum_or_filters_scores => :Boolean,
- :restrict_searchable_attributes => :'Array<String>',
- :facets => :'Array<String>',
- :faceting_after_distinct => :Boolean,
- :page => :Integer,
- :offset => :Integer,
- :length => :Integer,
- :around_lat_lng => :String,
- :around_lat_lng_via_ip => :Boolean,
- :around_radius => :AroundRadius,
- :around_precision => :AroundPrecision,
- :minimum_around_radius => :Integer,
- :inside_bounding_box => :'Array<Array<Float>>',
- :inside_polygon => :'Array<Array<Float>>',
- :natural_languages => :'Array<SupportedLanguage>',
- :rule_contexts => :'Array<String>',
- :personalization_impact => :Integer,
- :user_token => :String,
- :get_ranking_info => :Boolean,
- :synonyms => :Boolean,
- :click_analytics => :Boolean,
- :analytics => :Boolean,
- :analytics_tags => :'Array<String>',
- :percentile_computation => :Boolean,
- :enable_ab_test => :Boolean,
- :attributes_to_retrieve => :'Array<String>',
- :ranking => :'Array<String>',
- :custom_ranking => :'Array<String>',
- :relevancy_strictness => :Integer,
- :attributes_to_highlight => :'Array<String>',
- :attributes_to_snippet => :'Array<String>',
- :highlight_pre_tag => :String,
- :highlight_post_tag => :String,
- :snippet_ellipsis_text => :String,
- :restrict_highlight_and_snippet_arrays => :Boolean,
- :hits_per_page => :Integer,
- :min_word_sizefor1_typo => :Integer,
- :min_word_sizefor2_typos => :Integer,
- :typo_tolerance => :TypoTolerance,
- :allow_typos_on_numeric_tokens => :Boolean,
- :disable_typo_tolerance_on_attributes => :'Array<String>',
- :ignore_plurals => :IgnorePlurals,
- :remove_stop_words => :RemoveStopWords,
- :keep_diacritics_on_characters => :String,
- :query_languages => :'Array<SupportedLanguage>',
- :decompound_query => :Boolean,
- :enable_rules => :Boolean,
- :enable_personalization => :Boolean,
- :query_type => :QueryType,
- :remove_words_if_no_results => :RemoveWordsIfNoResults,
- :mode => :Mode,
- :semantic_search => :SemanticSearch,
- :advanced_syntax => :Boolean,
- :optional_words => :'Array<String>',
- :disable_exact_on_attributes => :'Array<String>',
- :exact_on_single_word_query => :ExactOnSingleWordQuery,
- :alternatives_as_exact => :'Array<AlternativesAsExact>',
- :advanced_syntax_features => :'Array<AdvancedSyntaxFeatures>',
- :distinct => :Distinct,
- :replace_synonyms_in_highlight => :Boolean,
- :min_proximity => :Integer,
- :response_fields => :'Array<String>',
- :max_facet_hits => :Integer,
- :max_values_per_facet => :Integer,
- :sort_facet_values_by => :String,
- :attribute_criteria_computed_by_min_proximity => :Boolean,
- :rendering_content => :RenderingContent,
- :enable_re_ranking => :Boolean,
- :re_ranking_apply_filter => :ReRankingApplyFilter
+ :query => :"String",
+ :similar_query => :"String",
+ :filters => :"String",
+ :facet_filters => :"FacetFilters",
+ :optional_filters => :"OptionalFilters",
+ :numeric_filters => :"NumericFilters",
+ :tag_filters => :"TagFilters",
+ :sum_or_filters_scores => :"Boolean",
+ :restrict_searchable_attributes => :"Array<String>",
+ :facets => :"Array<String>",
+ :faceting_after_distinct => :"Boolean",
+ :page => :"Integer",
+ :offset => :"Integer",
+ :length => :"Integer",
+ :around_lat_lng => :"String",
+ :around_lat_lng_via_ip => :"Boolean",
+ :around_radius => :"AroundRadius",
+ :around_precision => :"AroundPrecision",
+ :minimum_around_radius => :"Integer",
+ :inside_bounding_box => :"Array<Array<Float>>",
+ :inside_polygon => :"Array<Array<Float>>",
+ :natural_languages => :"Array<SupportedLanguage>",
+ :rule_contexts => :"Array<String>",
+ :personalization_impact => :"Integer",
+ :user_token => :"String",
+ :get_ranking_info => :"Boolean",
+ :synonyms => :"Boolean",
+ :click_analytics => :"Boolean",
+ :analytics => :"Boolean",
+ :analytics_tags => :"Array<String>",
+ :percentile_computation => :"Boolean",
+ :enable_ab_test => :"Boolean",
+ :attributes_to_retrieve => :"Array<String>",
+ :ranking => :"Array<String>",
+ :custom_ranking => :"Array<String>",
+ :relevancy_strictness => :"Integer",
+ :attributes_to_highlight => :"Array<String>",
+ :attributes_to_snippet => :"Array<String>",
+ :highlight_pre_tag => :"String",
+ :highlight_post_tag => :"String",
+ :snippet_ellipsis_text => :"String",
+ :restrict_highlight_and_snippet_arrays => :"Boolean",
+ :hits_per_page => :"Integer",
+ :min_word_sizefor1_typo => :"Integer",
+ :min_word_sizefor2_typos => :"Integer",
+ :typo_tolerance => :"TypoTolerance",
+ :allow_typos_on_numeric_tokens => :"Boolean",
+ :disable_typo_tolerance_on_attributes => :"Array<String>",
+ :ignore_plurals => :"IgnorePlurals",
+ :remove_stop_words => :"RemoveStopWords",
+ :keep_diacritics_on_characters => :"String",
+ :query_languages => :"Array<SupportedLanguage>",
+ :decompound_query => :"Boolean",
+ :enable_rules => :"Boolean",
+ :enable_personalization => :"Boolean",
+ :query_type => :"QueryType",
+ :remove_words_if_no_results => :"RemoveWordsIfNoResults",
+ :mode => :"Mode",
+ :semantic_search => :"SemanticSearch",
+ :advanced_syntax => :"Boolean",
+ :optional_words => :"Array<String>",
+ :disable_exact_on_attributes => :"Array<String>",
+ :exact_on_single_word_query => :"ExactOnSingleWordQuery",
+ :alternatives_as_exact => :"Array<AlternativesAsExact>",
+ :advanced_syntax_features => :"Array<AdvancedSyntaxFeatures>",
+ :distinct => :"Distinct",
+ :replace_synonyms_in_highlight => :"Boolean",
+ :min_proximity => :"Integer",
+ :response_fields => :"Array<String>",
+ :max_facet_hits => :"Integer",
+ :max_values_per_facet => :"Integer",
+ :sort_facet_values_by => :"String",
+ :attribute_criteria_computed_by_min_proximity => :"Boolean",
+ :rendering_content => :"RenderingContent",
+ :enable_re_ranking => :"Boolean",
+ :re_ranking_apply_filter => :"ReRankingApplyFilter"
}
end
# List of attributes with nullable: true
def self.openapi_nullable
- Set.new([
- :re_ranking_apply_filter
- ])
+ Set.new(
+ []
+ )
end
# List of class defined in allOf (OpenAPI v3)
def self.openapi_all_of
[
- :SearchParamsObject
+ :"SearchParamsObject"
]
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
- unless attributes.is_a?(Hash)
- raise ArgumentError, "The input argument (attributes) must be a hash in `Algolia::FallbackParams` initialize method"
+ if (!attributes.is_a?(Hash))
+ raise(
+ ArgumentError,
+ "The input argument (attributes) must be a hash in `Algolia::FallbackParams` initialize method"
+ )
end
# check to see if the attribute exists and convert string to symbol for hash key
- attributes = attributes.each_with_object({}) do |(k, v), h|
- unless self.class.attribute_map.key?(k.to_sym)
- raise ArgumentError,
- "`#{k}` is not a valid attribute in `Algolia::FallbackParams`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
+ attributes = attributes.each_with_object({}) { |(k, v), h|
+ if (!self.class.attribute_map.key?(k.to_sym))
+ raise(
+ ArgumentError,
+ "`#{k}` is not a valid attribute in `Algolia::FallbackParams`. Please check the name to make sure it's valid. List of attributes: " +
+ self.class.attribute_map.keys.inspect
+ )
end
h[k.to_sym] = v
- end
+ }
if attributes.key?(:query)
self.query = attributes[:query]
end
@@ -784,139 +790,138 @@
# Custom attribute writer method with validation
# @param [Object] page Value to be assigned
def page=(page)
if page.nil?
- raise ArgumentError, 'page cannot be nil'
+ raise ArgumentError, "page cannot be nil"
end
if page < 0
- raise ArgumentError, 'invalid value for "page", must be greater than or equal to 0.'
+ raise ArgumentError, "invalid value for \"page\", must be greater than or equal to 0."
end
@page = page
end
# Custom attribute writer method with validation
# @param [Object] length Value to be assigned
def length=(length)
if length.nil?
- raise ArgumentError, 'length cannot be nil'
+ raise ArgumentError, "length cannot be nil"
end
if length > 1000
- raise ArgumentError, 'invalid value for "length", must be smaller than or equal to 1000.'
+ raise ArgumentError, "invalid value for \"length\", must be smaller than or equal to 1000."
end
if length < 1
- raise ArgumentError, 'invalid value for "length", must be greater than or equal to 1.'
+ raise ArgumentError, "invalid value for \"length\", must be greater than or equal to 1."
end
@length = length
end
# Custom attribute writer method with validation
# @param [Object] minimum_around_radius Value to be assigned
def minimum_around_radius=(minimum_around_radius)
if minimum_around_radius.nil?
- raise ArgumentError, 'minimum_around_radius cannot be nil'
+ raise ArgumentError, "minimum_around_radius cannot be nil"
end
if minimum_around_radius < 1
- raise ArgumentError, 'invalid value for "minimum_around_radius", must be greater than or equal to 1.'
+ raise ArgumentError, "invalid value for \"minimum_around_radius\", must be greater than or equal to 1."
end
@minimum_around_radius = minimum_around_radius
end
# Custom attribute writer method with validation
# @param [Object] personalization_impact Value to be assigned
def personalization_impact=(personalization_impact)
if personalization_impact.nil?
- raise ArgumentError, 'personalization_impact cannot be nil'
+ raise ArgumentError, "personalization_impact cannot be nil"
end
if personalization_impact > 100
- raise ArgumentError, 'invalid value for "personalization_impact", must be smaller than or equal to 100.'
+ raise ArgumentError, "invalid value for \"personalization_impact\", must be smaller than or equal to 100."
end
if personalization_impact < 0
- raise ArgumentError, 'invalid value for "personalization_impact", must be greater than or equal to 0.'
+ raise ArgumentError, "invalid value for \"personalization_impact\", must be greater than or equal to 0."
end
@personalization_impact = personalization_impact
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'
+ 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.'
+ 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.'
+ raise ArgumentError, "invalid value for \"hits_per_page\", must be greater than or equal to 1."
end
@hits_per_page = hits_per_page
end
# Custom attribute writer method with validation
# @param [Object] min_proximity Value to be assigned
def min_proximity=(min_proximity)
if min_proximity.nil?
- raise ArgumentError, 'min_proximity cannot be nil'
+ raise ArgumentError, "min_proximity cannot be nil"
end
if min_proximity > 7
- raise ArgumentError, 'invalid value for "min_proximity", must be smaller than or equal to 7.'
+ raise ArgumentError, "invalid value for \"min_proximity\", must be smaller than or equal to 7."
end
if min_proximity < 1
- raise ArgumentError, 'invalid value for "min_proximity", must be greater than or equal to 1.'
+ raise ArgumentError, "invalid value for \"min_proximity\", must be greater than or equal to 1."
end
@min_proximity = min_proximity
end
# Custom attribute writer method with validation
# @param [Object] max_facet_hits Value to be assigned
def max_facet_hits=(max_facet_hits)
if max_facet_hits.nil?
- raise ArgumentError, 'max_facet_hits cannot be nil'
+ raise ArgumentError, "max_facet_hits cannot be nil"
end
if max_facet_hits > 100
- raise ArgumentError, 'invalid value for "max_facet_hits", must be smaller than or equal to 100.'
+ raise ArgumentError, "invalid value for \"max_facet_hits\", must be smaller than or equal to 100."
end
@max_facet_hits = max_facet_hits
end
# Custom attribute writer method with validation
# @param [Object] max_values_per_facet Value to be assigned
def max_values_per_facet=(max_values_per_facet)
if max_values_per_facet.nil?
- raise ArgumentError, 'max_values_per_facet cannot be nil'
+ raise ArgumentError, "max_values_per_facet cannot be nil"
end
if max_values_per_facet > 1000
- raise ArgumentError, 'invalid value for "max_values_per_facet", must be smaller than or equal to 1000.'
+ raise ArgumentError, "invalid value for \"max_values_per_facet\", must be smaller than or equal to 1000."
end
@max_values_per_facet = max_values_per_facet
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(other)
- return true if equal?(other)
-
+ return true if self.equal?(other)
self.class == other.class &&
query == other.query &&
similar_query == other.similar_query &&
filters == other.filters &&
facet_filters == other.facet_filters &&
@@ -1001,35 +1006,113 @@
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
def hash
- [query, similar_query, filters, facet_filters, optional_filters, numeric_filters, tag_filters, sum_or_filters_scores, restrict_searchable_attributes, facets,
- faceting_after_distinct, page, offset, length, around_lat_lng, around_lat_lng_via_ip, around_radius, around_precision, minimum_around_radius, inside_bounding_box, inside_polygon, natural_languages, rule_contexts, personalization_impact, user_token, get_ranking_info, synonyms, click_analytics, analytics, analytics_tags, percentile_computation, enable_ab_test, attributes_to_retrieve, ranking, custom_ranking, relevancy_strictness, attributes_to_highlight, attributes_to_snippet, highlight_pre_tag, highlight_post_tag, snippet_ellipsis_text, restrict_highlight_and_snippet_arrays, hits_per_page, min_word_sizefor1_typo, min_word_sizefor2_typos, typo_tolerance, allow_typos_on_numeric_tokens, disable_typo_tolerance_on_attributes, ignore_plurals, remove_stop_words, keep_diacritics_on_characters, query_languages, decompound_query, enable_rules, enable_personalization, query_type, remove_words_if_no_results, mode, semantic_search, advanced_syntax, optional_words, disable_exact_on_attributes, exact_on_single_word_query, alternatives_as_exact, advanced_syntax_features, distinct, replace_synonyms_in_highlight, min_proximity, response_fields, max_facet_hits, max_values_per_facet, sort_facet_values_by, attribute_criteria_computed_by_min_proximity, rendering_content, enable_re_ranking, re_ranking_apply_filter].hash
+ [
+ query,
+ similar_query,
+ filters,
+ facet_filters,
+ optional_filters,
+ numeric_filters,
+ tag_filters,
+ sum_or_filters_scores,
+ restrict_searchable_attributes,
+ facets,
+ faceting_after_distinct,
+ page,
+ offset,
+ length,
+ around_lat_lng,
+ around_lat_lng_via_ip,
+ around_radius,
+ around_precision,
+ minimum_around_radius,
+ inside_bounding_box,
+ inside_polygon,
+ natural_languages,
+ rule_contexts,
+ personalization_impact,
+ user_token,
+ get_ranking_info,
+ synonyms,
+ click_analytics,
+ analytics,
+ analytics_tags,
+ percentile_computation,
+ enable_ab_test,
+ attributes_to_retrieve,
+ ranking,
+ custom_ranking,
+ relevancy_strictness,
+ attributes_to_highlight,
+ attributes_to_snippet,
+ highlight_pre_tag,
+ highlight_post_tag,
+ snippet_ellipsis_text,
+ restrict_highlight_and_snippet_arrays,
+ hits_per_page,
+ min_word_sizefor1_typo,
+ min_word_sizefor2_typos,
+ typo_tolerance,
+ allow_typos_on_numeric_tokens,
+ disable_typo_tolerance_on_attributes,
+ ignore_plurals,
+ remove_stop_words,
+ keep_diacritics_on_characters,
+ query_languages,
+ decompound_query,
+ enable_rules,
+ enable_personalization,
+ query_type,
+ remove_words_if_no_results,
+ mode,
+ semantic_search,
+ advanced_syntax,
+ optional_words,
+ disable_exact_on_attributes,
+ exact_on_single_word_query,
+ alternatives_as_exact,
+ advanced_syntax_features,
+ distinct,
+ replace_synonyms_in_highlight,
+ min_proximity,
+ response_fields,
+ max_facet_hits,
+ max_values_per_facet,
+ sort_facet_values_by,
+ attribute_criteria_computed_by_min_proximity,
+ rendering_content,
+ enable_re_ranking,
+ re_ranking_apply_filter
+ ].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def self.build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
-
attributes = attributes.transform_keys(&:to_sym)
transformed_hash = {}
types_mapping.each_pair do |key, type|
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
transformed_hash[key.to_sym] = nil
elsif type =~ /\AArray<(.*)>/i
# check to ensure the input is an array given that the attribute
# is documented as an array but the input is not
if attributes[attribute_map[key]].is_a?(Array)
- transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v| _deserialize(::Regexp.last_match(1), v) }
+ transformed_hash[key.to_sym] = attributes[attribute_map[key]].map { |v|
+ _deserialize(::Regexp.last_match(1), v)
+ }
end
elsif !attributes[attribute_map[key]].nil?
transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
end
end
+
new(transformed_hash)
end
# Deserializes the data based on type
# @param string type Data type
@@ -1051,10 +1134,11 @@
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
+
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
@@ -1065,14 +1149,16 @@
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
- else # model
+ # model
+ else
# models (e.g. Pet) or oneOf
klass = Algolia::Recommend.const_get(type)
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass
+ .build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
@@ -1101,10 +1187,11 @@
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
end
hash[param] = _to_hash(value)
end
+
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
@@ -1115,14 +1202,16 @@
value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
- elsif value.respond_to? :to_hash
+ elsif value.respond_to?(:to_hash)
value.to_hash
else
value
end
end
+
end
+
end
end