Class: Fassbinder::Request

Inherits:
Sucker::Request
  • Object
show all
Defined in:
lib/fassbinder/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Request

Returns a new instance of Request.



6
7
8
9
10
11
12
13
14
# File 'lib/fassbinder/request.rb', line 6

def initialize(args = {})
  super
  self.<<({
    'Operation'                       => 'ItemLookup',
    'ItemLookup.Shared.IdType'        => 'ASIN',
    'ItemLookup.Shared.Condition'     => 'All',
    'ItemLookup.Shared.MerchantId'    => 'All',
    'ItemLookup.Shared.ResponseGroup' => ['OfferFull'] })
end

Instance Method Details

#batchify(asins) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/fassbinder/request.rb', line 16

def batchify(asins)
  asins = [asins].flatten

  if asins.size > 20
    raise ArgumentError, 'You cannot add more than 20 ASINs to a batch'
  end

  self.<<({ 'ItemLookup.1.ItemId' => asins[0, 10] })
  self.<<({ 'ItemLookup.2.ItemId' => asins[10, 10] }) if asins.size > 10
end

#getObject



27
28
29
# File 'lib/fassbinder/request.rb', line 27

def get
  Response.new(super, locale)
end