class AliseeksApi::SearchRequest
Non realtime search request body
Attributes
The AliExpress category to search in
Filter by freight types
When this flag is set to `true` the `category` field will be expanded so that all items in sub-categories will be included
Limit the request to a number of items
The scroll identifier which can be retrieved by sending an initial search request with `scrollPagination` set to `true`. Scroll identifiers are good for 60 seconds.
When this value is `true` then you will receive a scroll identifier which you can use to request the next page of results. The scroll identifier is good for 60 seconds.
Skip a number of items, if you need to skip more than 10000 items then use the scroll feature
The direction to sort the results by. Only valid for certain `sort` values
The search query
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/aliseeks_api/models/search_request.rb, line 84 def self.attribute_map { :'text' => :'text', :'sort' => :'sort', :'currency' => :'currency', :'category' => :'category', :'include_subcategories' => :'includeSubcategories', :'sort_direction' => :'sortDirection', :'ratings_range' => :'ratingsRange', :'quantity_range' => :'quantityRange', :'price_range' => :'priceRange', :'unit_price_range' => :'unitPriceRange', :'order_range' => :'orderRange', :'item_id_range' => :'itemIdRange', :'freight_types' => :'freightTypes', :'skip' => :'skip', :'limit' => :'limit', :'scroll_pagination' => :'scrollPagination', :'scroll_identifier' => :'scrollIdentifier' } end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/aliseeks_api/models/search_request.rb, line 131 def initialize(attributes = {}) return unless attributes.is_a?(Hash) # convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v } if attributes.has_key?(:'text') self.text = attributes[:'text'] end if attributes.has_key?(:'sort') self.sort = attributes[:'sort'] else self.sort = 'BEST_MATCH' end if attributes.has_key?(:'currency') self.currency = attributes[:'currency'] end if attributes.has_key?(:'category') self.category = attributes[:'category'] end if attributes.has_key?(:'includeSubcategories') self.include_subcategories = attributes[:'includeSubcategories'] else self.include_subcategories = false end if attributes.has_key?(:'sortDirection') self.sort_direction = attributes[:'sortDirection'] else self.sort_direction = 'ASC' end if attributes.has_key?(:'ratingsRange') self.ratings_range = attributes[:'ratingsRange'] end if attributes.has_key?(:'quantityRange') self.quantity_range = attributes[:'quantityRange'] end if attributes.has_key?(:'priceRange') self.price_range = attributes[:'priceRange'] end if attributes.has_key?(:'unitPriceRange') self.unit_price_range = attributes[:'unitPriceRange'] end if attributes.has_key?(:'orderRange') self.order_range = attributes[:'orderRange'] end if attributes.has_key?(:'itemIdRange') self.item_id_range = attributes[:'itemIdRange'] end if attributes.has_key?(:'freightTypes') if (value = attributes[:'freightTypes']).is_a?(Array) self.freight_types = value end end if attributes.has_key?(:'skip') self.skip = attributes[:'skip'] end if attributes.has_key?(:'limit') self.limit = attributes[:'limit'] end if attributes.has_key?(:'scrollPagination') self.scroll_pagination = attributes[:'scrollPagination'] else self.scroll_pagination = false end if attributes.has_key?(:'scrollIdentifier') self.scroll_identifier = attributes[:'scrollIdentifier'] end end
Attribute type mapping.
# File lib/aliseeks_api/models/search_request.rb, line 107 def self.openapi_types { :'text' => :'String', :'sort' => :'String', :'currency' => :'NonRealtimeCurrency', :'category' => :'Integer', :'include_subcategories' => :'BOOLEAN', :'sort_direction' => :'String', :'ratings_range' => :'DoubleRange', :'quantity_range' => :'IntegerRange', :'price_range' => :'DoubleRange', :'unit_price_range' => :'DoubleRange', :'order_range' => :'IntegerRange', :'item_id_range' => :'StringRange', :'freight_types' => :'Array<String>', :'skip' => :'Integer', :'limit' => :'Integer', :'scroll_pagination' => :'BOOLEAN', :'scroll_identifier' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/aliseeks_api/models/search_request.rb, line 303 def ==(o) return true if self.equal?(o) self.class == o.class && text == o.text && sort == o.sort && currency == o.currency && category == o.category && include_subcategories == o.include_subcategories && sort_direction == o.sort_direction && ratings_range == o.ratings_range && quantity_range == o.quantity_range && price_range == o.price_range && unit_price_range == o.unit_price_range && order_range == o.order_range && item_id_range == o.item_id_range && freight_types == o.freight_types && skip == o.skip && limit == o.limit && scroll_pagination == o.scroll_pagination && scroll_identifier == o.scroll_identifier end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/aliseeks_api/models/search_request.rb, line 361 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.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 temp_model = AliseeksApi.const_get(type).new temp_model.build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/aliseeks_api/models/search_request.rb, line 427 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/aliseeks_api/models/search_request.rb, line 340 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
@see the `==` method @param [Object] Object to be compared
# File lib/aliseeks_api/models/search_request.rb, line 327 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Fixnum] Hash code
# File lib/aliseeks_api/models/search_request.rb, line 333 def hash [text, sort, currency, category, include_subcategories, sort_direction, ratings_range, quantity_range, price_range, unit_price_range, order_range, item_id_range, freight_types, skip, limit, scroll_pagination, scroll_identifier].hash end
Custom attribute writer method with validation @param [Object] limit Value to be assigned
# File lib/aliseeks_api/models/search_request.rb, line 289 def limit=(limit) if !limit.nil? && limit > 50 fail ArgumentError, 'invalid value for "limit", must be smaller than or equal to 50.' end if !limit.nil? && limit < 5 fail ArgumentError, 'invalid value for "limit", must be greater than or equal to 5.' end @limit = limit end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/aliseeks_api/models/search_request.rb, line 218 def list_invalid_properties invalid_properties = Array.new if !@skip.nil? && @skip > 10000 invalid_properties.push('invalid value for "skip", must be smaller than or equal to 10000.') end if !@skip.nil? && @skip < 0 invalid_properties.push('invalid value for "skip", must be greater than or equal to 0.') end if !@limit.nil? && @limit > 50 invalid_properties.push('invalid value for "limit", must be smaller than or equal to 50.') end if !@limit.nil? && @limit < 5 invalid_properties.push('invalid value for "limit", must be greater than or equal to 5.') end invalid_properties end
Custom attribute writer method with validation @param [Object] skip Value to be assigned
# File lib/aliseeks_api/models/search_request.rb, line 275 def skip=(skip) if !skip.nil? && skip > 10000 fail ArgumentError, 'invalid value for "skip", must be smaller than or equal to 10000.' end if !skip.nil? && skip < 0 fail ArgumentError, 'invalid value for "skip", must be greater than or equal to 0.' end @skip = skip end
Custom attribute writer method checking allowed values (enum). @param [Object] sort Object to be assigned
# File lib/aliseeks_api/models/search_request.rb, line 255 def sort=(sort) validator = EnumAttributeValidator.new('String', ['PRODUCT_ID', 'UPDATE_TIME', 'WHOLESALE_PRICE', 'ITEM_RATING', 'ORDERS', 'BEST_MATCH']) unless validator.valid?(sort) fail ArgumentError, 'invalid value for "sort", must be one of #{validator.allowable_values}.' end @sort = sort end
Custom attribute writer method checking allowed values (enum). @param [Object] sort_direction
Object to be assigned
# File lib/aliseeks_api/models/search_request.rb, line 265 def sort_direction=(sort_direction) validator = EnumAttributeValidator.new('String', ['ASC', 'DESC']) unless validator.valid?(sort_direction) fail ArgumentError, 'invalid value for "sort_direction", must be one of #{validator.allowable_values}.' end @sort_direction = sort_direction end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/aliseeks_api/models/search_request.rb, line 413 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/aliseeks_api/models/search_request.rb, line 401 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/aliseeks_api/models/search_request.rb, line 241 def valid? sort_validator = EnumAttributeValidator.new('String', ['PRODUCT_ID', 'UPDATE_TIME', 'WHOLESALE_PRICE', 'ITEM_RATING', 'ORDERS', 'BEST_MATCH']) return false unless sort_validator.valid?(@sort) sort_direction_validator = EnumAttributeValidator.new('String', ['ASC', 'DESC']) return false unless sort_direction_validator.valid?(@sort_direction) return false if !@skip.nil? && @skip > 10000 return false if !@skip.nil? && @skip < 0 return false if !@limit.nil? && @limit > 50 return false if !@limit.nil? && @limit < 5 true end