class Algolia::Search::BaseSearchResponse

def self._deserialize(type, value)

Returns:
  • (Object) - Deserialized data

Parameters:
  • string () -- value Value to be deserialized
  • string () -- type Data type
def self._deserialize(type, value)
  case type.to_sym
  when :Time
    Time.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :Boolean
    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]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    # models (e.g. Pet) or oneOf
    klass = Algolia::Search.const_get(type)
    klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
  end
end

def self.acceptable_attributes

Returns all the JSON keys this model knows about
def self.acceptable_attributes
  attribute_map.values
end

def self.attribute_map

Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
  {
    :ab_test_id => :abTestID,
    :ab_test_variant_id => :abTestVariantID,
    :around_lat_lng => :aroundLatLng,
    :automatic_radius => :automaticRadius,
    :exhaustive => :exhaustive,
    :exhaustive_facets_count => :exhaustiveFacetsCount,
    :exhaustive_nb_hits => :exhaustiveNbHits,
    :exhaustive_typo => :exhaustiveTypo,
    :facets => :facets,
    :facets_stats => :facets_stats,
    :hits_per_page => :hitsPerPage,
    :index => :index,
    :index_used => :indexUsed,
    :message => :message,
    :nb_hits => :nbHits,
    :nb_pages => :nbPages,
    :nb_sorted_hits => :nbSortedHits,
    :page => :page,
    :parsed_query => :parsedQuery,
    :processing_time_ms => :processingTimeMS,
    :processing_timings_ms => :processingTimingsMS,
    :query_after_removal => :queryAfterRemoval,
    :redirect => :redirect,
    :rendering_content => :renderingContent,
    :server_time_ms => :serverTimeMS,
    :server_used => :serverUsed,
    :user_data => :userData,
    :query_id => :queryID
  }
end

def self.build_from_hash(attributes)

Returns:
  • (Object) - Returns the model itself

Parameters:
  • attributes (Hash) -- Model attributes in the form of hash
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) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash[key.to_sym] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  # add extra attribute to transformed_hash
  transformed_hash.merge!(attributes.reject { |k, _| attribute_map.key?(k.to_sym) })
  new(transformed_hash)
end

def self.openapi_nullable

List of attributes with nullable: true
def self.openapi_nullable
  Set.new([])
end

def self.types_mapping

Attribute type mapping.
def self.types_mapping
  {
    :ab_test_id => :Integer,
    :ab_test_variant_id => :Integer,
    :around_lat_lng => :String,
    :automatic_radius => :String,
    :exhaustive => :Exhaustive,
    :exhaustive_facets_count => :Boolean,
    :exhaustive_nb_hits => :Boolean,
    :exhaustive_typo => :Boolean,
    :facets => :'Hash<String, Hash<String, Integer>>',
    :facets_stats => :'Hash<String, FacetsStats>',
    :hits_per_page => :Integer,
    :index => :String,
    :index_used => :String,
    :message => :String,
    :nb_hits => :Integer,
    :nb_pages => :Integer,
    :nb_sorted_hits => :Integer,
    :page => :Integer,
    :parsed_query => :String,
    :processing_time_ms => :Integer,
    :processing_timings_ms => :Object,
    :query_after_removal => :String,
    :redirect => :Redirect,
    :rendering_content => :RenderingContent,
    :server_time_ms => :Integer,
    :server_used => :String,
    :user_data => :Object,
    :query_id => :String
  }
end

def ==(other)

Parameters:
  • Object (Object) -- to be compared
def ==(other)
  return true if equal?(other)
  self.class == other.class &&
    ab_test_id == other.ab_test_id &&
    ab_test_variant_id == other.ab_test_variant_id &&
    around_lat_lng == other.around_lat_lng &&
    automatic_radius == other.automatic_radius &&
    exhaustive == other.exhaustive &&
    exhaustive_facets_count == other.exhaustive_facets_count &&
    exhaustive_nb_hits == other.exhaustive_nb_hits &&
    exhaustive_typo == other.exhaustive_typo &&
    facets == other.facets &&
    facets_stats == other.facets_stats &&
    hits_per_page == other.hits_per_page &&
    index == other.index &&
    index_used == other.index_used &&
    message == other.message &&
    nb_hits == other.nb_hits &&
    nb_pages == other.nb_pages &&
    nb_sorted_hits == other.nb_sorted_hits &&
    page == other.page &&
    parsed_query == other.parsed_query &&
    processing_time_ms == other.processing_time_ms &&
    processing_timings_ms == other.processing_timings_ms &&
    query_after_removal == other.query_after_removal &&
    redirect == other.redirect &&
    rendering_content == other.rendering_content &&
    server_time_ms == other.server_time_ms &&
    server_used == other.server_used &&
    user_data == other.user_data &&
    query_id == other.query_id
end

def _to_hash(value)

Returns:
  • (Hash) - Returns the value in the form of hash

Parameters:
  • value (Object) -- Any valid value
def _to_hash(value)
  if value.is_a?(Array)
    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
    value.to_hash
  else
    value
  end
end

def ab_test_variant_id=(ab_test_variant_id)

Parameters:
  • ab_test_variant_id (Object) -- Value to be assigned
def ab_test_variant_id=(ab_test_variant_id)
  if ab_test_variant_id.nil?
    raise ArgumentError, 'ab_test_variant_id cannot be nil'
  end
  if ab_test_variant_id < 1
    raise ArgumentError, 'invalid value for "ab_test_variant_id", must be greater than or equal to 1.'
  end
  @ab_test_variant_id = ab_test_variant_id
end

def around_lat_lng=(around_lat_lng)

Parameters:
  • around_lat_lng (Object) -- Value to be assigned
def around_lat_lng=(around_lat_lng)
  if around_lat_lng.nil?
    raise ArgumentError, 'around_lat_lng cannot be nil'
  end
  pattern = /^(-?\d+(\.\d+)?),\s*(-?\d+(\.\d+)?)$/
  if around_lat_lng !~ pattern
    raise ArgumentError, "invalid value for \"around_lat_lng\", must conform to the pattern #{pattern}."
  end
  @around_lat_lng = around_lat_lng
end

def eql?(other)

Parameters:
  • Object (Object) -- to be compared

Other tags:
    See: the - `==` method
def eql?(other)
  self == other
end

def hash

Returns:
  • (Integer) - Hash code
def hash
  [ab_test_id, ab_test_variant_id, around_lat_lng, automatic_radius, exhaustive, exhaustive_facets_count, exhaustive_nb_hits, exhaustive_typo, facets, facets_stats,
   hits_per_page, index, index_used, message, nb_hits, nb_pages, nb_sorted_hits, page, parsed_query, processing_time_ms, processing_timings_ms, query_after_removal, redirect, rendering_content, server_time_ms, server_used, user_data, query_id].hash
end

def hits_per_page=(hits_per_page)

Parameters:
  • hits_per_page (Object) -- 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

def initialize(attributes = {})

Parameters:
  • attributes (Hash) -- 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::BaseSearchResponse` initialize method"
  end
  if attributes.key?(:ab_test_id)
    self.ab_test_id = attributes[:ab_test_id]
  end
  if attributes.key?(:ab_test_variant_id)
    self.ab_test_variant_id = attributes[:ab_test_variant_id]
  end
  if attributes.key?(:around_lat_lng)
    self.around_lat_lng = attributes[:around_lat_lng]
  end
  if attributes.key?(:automatic_radius)
    self.automatic_radius = attributes[:automatic_radius]
  end
  if attributes.key?(:exhaustive)
    self.exhaustive = attributes[:exhaustive]
  end
  if attributes.key?(:exhaustive_facets_count)
    self.exhaustive_facets_count = attributes[:exhaustive_facets_count]
  end
  if attributes.key?(:exhaustive_nb_hits)
    self.exhaustive_nb_hits = attributes[:exhaustive_nb_hits]
  end
  if attributes.key?(:exhaustive_typo)
    self.exhaustive_typo = attributes[:exhaustive_typo]
  end
  if attributes.key?(:facets)
    if (value = attributes[:facets]).is_a?(Hash)
      self.facets = value
    end
  end
  if attributes.key?(:facets_stats)
    if (value = attributes[:facets_stats]).is_a?(Hash)
      self.facets_stats = value
    end
  end
  if attributes.key?(:hits_per_page)
    self.hits_per_page = attributes[:hits_per_page]
  else
    self.hits_per_page = nil
  end
  if attributes.key?(:index)
    self.index = attributes[:index]
  end
  if attributes.key?(:index_used)
    self.index_used = attributes[:index_used]
  end
  if attributes.key?(:message)
    self.message = attributes[:message]
  end
  if attributes.key?(:nb_hits)
    self.nb_hits = attributes[:nb_hits]
  else
    self.nb_hits = nil
  end
  if attributes.key?(:nb_pages)
    self.nb_pages = attributes[:nb_pages]
  else
    self.nb_pages = nil
  end
  if attributes.key?(:nb_sorted_hits)
    self.nb_sorted_hits = attributes[:nb_sorted_hits]
  end
  if attributes.key?(:page)
    self.page = attributes[:page]
  else
    self.page = nil
  end
  if attributes.key?(:parsed_query)
    self.parsed_query = attributes[:parsed_query]
  end
  if attributes.key?(:processing_time_ms)
    self.processing_time_ms = attributes[:processing_time_ms]
  else
    self.processing_time_ms = nil
  end
  if attributes.key?(:processing_timings_ms)
    self.processing_timings_ms = attributes[:processing_timings_ms]
  end
  if attributes.key?(:query_after_removal)
    self.query_after_removal = attributes[:query_after_removal]
  end
  if attributes.key?(:redirect)
    self.redirect = attributes[:redirect]
  end
  if attributes.key?(:rendering_content)
    self.rendering_content = attributes[:rendering_content]
  end
  if attributes.key?(:server_time_ms)
    self.server_time_ms = attributes[:server_time_ms]
  end
  if attributes.key?(:server_used)
    self.server_used = attributes[:server_used]
  end
  if attributes.key?(:user_data)
    self.user_data = attributes[:user_data]
  end
  if attributes.key?(:query_id)
    self.query_id = attributes[:query_id]
  end
  # add extra attribute to additional_properties
  self.additional_properties ||= {}
  self.additional_properties.merge!(attributes.reject { |k, _| self.class.attribute_map.key?(k.to_sym) })
end

def page=(page)

Parameters:
  • page (Object) -- Value to be assigned
def page=(page)
  if page.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.'
  end
  @page = page
end

def to_body

Returns:
  • (Hash) - Returns the object in the form of hash
def to_body
  to_hash
end

def to_hash

Returns:
  • (Hash) - Returns the object in the form of hash
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end
    hash[param] = _to_hash(value)
  end
  # also add attributes from additional_properties to hash
  self.additional_properties&.each_pair do |k, v|
    hash[k.to_sym] = _to_hash(v)
  end
  hash
end

def to_json(*_args)

def to_json(*_args)
  to_hash.to_json
end

def to_s

Returns:
  • (String) - String presentation of the object
def to_s
  to_hash.to_s
end