Class: AliseeksApi::SearchRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/aliseeks_api/models/search_request.rb

Overview

Non realtime search request body

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ SearchRequest

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# 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

Instance Attribute Details

#categoryObject

The AliExpress category to search in



26
27
28
# File 'lib/aliseeks_api/models/search_request.rb', line 26

def category
  @category
end

#currencyObject

Returns the value of attribute currency.



23
24
25
# File 'lib/aliseeks_api/models/search_request.rb', line 23

def currency
  @currency
end

#freight_typesObject

Filter by freight types



47
48
49
# File 'lib/aliseeks_api/models/search_request.rb', line 47

def freight_types
  @freight_types
end

#include_subcategoriesObject

When this flag is set to ‘true` the `category` field will be expanded so that all items in sub-categories will be included



29
30
31
# File 'lib/aliseeks_api/models/search_request.rb', line 29

def include_subcategories
  @include_subcategories
end

#item_id_rangeObject

Returns the value of attribute item_id_range.



44
45
46
# File 'lib/aliseeks_api/models/search_request.rb', line 44

def item_id_range
  @item_id_range
end

#limitObject

Limit the request to a number of items



53
54
55
# File 'lib/aliseeks_api/models/search_request.rb', line 53

def limit
  @limit
end

#order_rangeObject

Returns the value of attribute order_range.



42
43
44
# File 'lib/aliseeks_api/models/search_request.rb', line 42

def order_range
  @order_range
end

#price_rangeObject

Returns the value of attribute price_range.



38
39
40
# File 'lib/aliseeks_api/models/search_request.rb', line 38

def price_range
  @price_range
end

#quantity_rangeObject

Returns the value of attribute quantity_range.



36
37
38
# File 'lib/aliseeks_api/models/search_request.rb', line 36

def quantity_range
  @quantity_range
end

#ratings_rangeObject

Returns the value of attribute ratings_range.



34
35
36
# File 'lib/aliseeks_api/models/search_request.rb', line 34

def ratings_range
  @ratings_range
end

#scroll_identifierObject

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.



59
60
61
# File 'lib/aliseeks_api/models/search_request.rb', line 59

def scroll_identifier
  @scroll_identifier
end

#scroll_paginationObject

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.



56
57
58
# File 'lib/aliseeks_api/models/search_request.rb', line 56

def scroll_pagination
  @scroll_pagination
end

#skipObject

Skip a number of items, if you need to skip more than 10000 items then use the scroll feature



50
51
52
# File 'lib/aliseeks_api/models/search_request.rb', line 50

def skip
  @skip
end

#sortObject

Returns the value of attribute sort.



21
22
23
# File 'lib/aliseeks_api/models/search_request.rb', line 21

def sort
  @sort
end

#sort_directionObject

The direction to sort the results by. Only valid for certain ‘sort` values



32
33
34
# File 'lib/aliseeks_api/models/search_request.rb', line 32

def sort_direction
  @sort_direction
end

#textObject

The search query



19
20
21
# File 'lib/aliseeks_api/models/search_request.rb', line 19

def text
  @text
end

#unit_price_rangeObject

Returns the value of attribute unit_price_range.



40
41
42
# File 'lib/aliseeks_api/models/search_request.rb', line 40

def unit_price_range
  @unit_price_range
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# 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

.openapi_typesObject

Attribute type mapping.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# 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

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# 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

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type

Parameters:

  • string

    type Data type

  • string

    value Value to be deserialized

Returns:

  • (Object)

    Deserialized data



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# 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

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value

Parameters:

  • value (Object)

    Any valid value

Returns:

  • (Hash)

    Returns the value in the form of hash



427
428
429
430
431
432
433
434
435
436
437
438
439
# 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

#build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# 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

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


327
328
329
# File 'lib/aliseeks_api/models/search_request.rb', line 327

def eql?(o)
  self == o
end

#hashFixnum

Calculates hash code according to all attributes.

Returns:

  • (Fixnum)

    Hash code



333
334
335
# 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

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# 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

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)

Returns:

  • (Hash)

    Returns the object in the form of hash



407
408
409
# File 'lib/aliseeks_api/models/search_request.rb', line 407

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



413
414
415
416
417
418
419
420
421
# 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

#to_sString

Returns the string representation of the object

Returns:

  • (String)

    String presentation of the object



401
402
403
# File 'lib/aliseeks_api/models/search_request.rb', line 401

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



241
242
243
244
245
246
247
248
249
250
251
# 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