lib/algolia/models/search/search_response.rb in algolia-3.0.0.beta.8 vs lib/algolia/models/search/search_response.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 Search
class SearchResponse
# A/B test ID. This is only included in the response for indices that are part of an A/B test.
@@ -33,34 +33,22 @@
attr_accessor :facets
# Statistics for numerical facets.
attr_accessor :facets_stats
- # Number of hits per page.
- attr_accessor :hits_per_page
-
# Index name used for the query.
attr_accessor :index
# Index name used for the query. During A/B testing, the targeted index isn't always the index used by the query.
attr_accessor :index_used
# Warnings about the query.
attr_accessor :message
- # Number of results (hits).
- attr_accessor :nb_hits
-
- # Number of pages of results.
- attr_accessor :nb_pages
-
# Number of hits selected and sorted by the relevant sort algorithm.
attr_accessor :nb_sorted_hits
- # Page of search results to retrieve.
- attr_accessor :page
-
# Post-[normalization](https://www.algolia.com/doc/guides/managing-results/optimize-search-results/handling-natural-languages-nlp/#what-does-normalization-mean) query string that will be searched.
attr_accessor :parsed_query
# Time the server took to process the request, in milliseconds.
attr_accessor :processing_time_ms
@@ -85,10 +73,22 @@
attr_accessor :user_data
# Unique identifier for the query. This is used for [click analytics](https://www.algolia.com/doc/guides/analytics/click-analytics/).
attr_accessor :query_id
+ # Page of search results to retrieve.
+ attr_accessor :page
+
+ # Number of results (hits).
+ attr_accessor :nb_hits
+
+ # Number of pages of results.
+ attr_accessor :nb_pages
+
+ # Number of hits per page.
+ attr_accessor :hits_per_page
+
# Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting.
attr_accessor :hits
# Search query.
attr_accessor :query
@@ -109,28 +109,28 @@
: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,
+ :page => :page,
+ :nb_hits => :nbHits,
+ :nb_pages => :nbPages,
+ :hits_per_page => :hitsPerPage,
:hits => :hits,
:query => :query,
:params => :params
}
end
@@ -141,62 +141,68 @@
end
# 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,
- :hits => :'Array<Hit>',
- :query => :String,
- :params => :String
+ :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>",
+ :index => :"String",
+ :index_used => :"String",
+ :message => :"String",
+ :nb_sorted_hits => :"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",
+ :page => :"Integer",
+ :nb_hits => :"Integer",
+ :nb_pages => :"Integer",
+ :hits_per_page => :"Integer",
+ :hits => :"Array<Hit>",
+ :query => :"String",
+ :params => :"String"
}
end
# List of attributes with nullable: true
def self.openapi_nullable
- Set.new([])
+ Set.new(
+ []
+ )
end
# List of class defined in allOf (OpenAPI v3)
def self.openapi_all_of
[
- :BaseSearchResponse,
- :SearchHits
+ :"BaseSearchResponse",
+ :"SearchHits",
+ :"SearchPagination"
]
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::SearchResponse` initialize method"
+ if (!attributes.is_a?(Hash))
+ raise(
+ ArgumentError,
+ "The input argument (attributes) must be a hash in `Algolia::SearchResponse` initialize method"
+ )
end
if attributes.key?(:ab_test_id)
self.ab_test_id = attributes[:ab_test_id]
end
@@ -239,16 +245,10 @@
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)
@@ -257,32 +257,14 @@
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)
@@ -321,10 +303,34 @@
if attributes.key?(:query_id)
self.query_id = attributes[:query_id]
end
+ if attributes.key?(:page)
+ self.page = attributes[:page]
+ else
+ self.page = nil
+ 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?(:hits_per_page)
+ self.hits_per_page = attributes[:hits_per_page]
+ else
+ self.hits_per_page = nil
+ end
+
if attributes.key?(:hits)
if (value = attributes[:hits]).is_a?(Array)
self.hits = value
end
else
@@ -350,25 +356,25 @@
# Custom attribute writer method with validation
# @param [Object] ab_test_variant_id 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'
+ 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.'
+ 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
# Custom attribute writer method with validation
# @param [Object] around_lat_lng Value to be assigned
def around_lat_lng=(around_lat_lng)
if around_lat_lng.nil?
- raise ArgumentError, 'around_lat_lng cannot be 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}."
@@ -376,46 +382,45 @@
@around_lat_lng = around_lat_lng
end
# 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"
+ end
+
+ if page < 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] 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] page 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
-
# 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 &&
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 &&
@@ -423,28 +428,28 @@
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 &&
+ page == other.page &&
+ nb_hits == other.nb_hits &&
+ nb_pages == other.nb_pages &&
+ hits_per_page == other.hits_per_page &&
hits == other.hits &&
query == other.query &&
params == other.params
end
@@ -455,30 +460,62 @@
end
# Calculates hash code according to all attributes.
# @return [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, hits, query, params].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,
+ index,
+ index_used,
+ message,
+ nb_sorted_hits,
+ parsed_query,
+ processing_time_ms,
+ processing_timings_ms,
+ query_after_removal,
+ redirect,
+ rendering_content,
+ server_time_ms,
+ server_used,
+ user_data,
+ query_id,
+ page,
+ nb_hits,
+ nb_pages,
+ hits_per_page,
+ hits,
+ query,
+ params
+ ].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
@@ -508,10 +545,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]
@@ -522,14 +560,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::Search.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
@@ -563,10 +603,11 @@
# 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
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
@@ -577,14 +618,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