Sha256: 93d009c04b7db512c8d05c67973b2fdfe2682e45abda4477154781bd6737720c

Contents?: true

Size: 819 Bytes

Versions: 7

Compression:

Stored size: 819 Bytes

Contents

require 'sucker'
require 'fassbinder/response'

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

    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

    def get
      Response.new(super, locale)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
fassbinder-0.0.15 lib/fassbinder/request.rb
fassbinder-0.0.14 lib/fassbinder/request.rb
fassbinder-0.0.13 lib/fassbinder/request.rb
fassbinder-0.0.12 lib/fassbinder/request.rb
fassbinder-0.0.11 lib/fassbinder/request.rb
fassbinder-0.0.10 lib/fassbinder/request.rb
fassbinder-0.0.9 lib/fassbinder/request.rb