Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

executable file 56 lines (45 sloc) 1.558 kb
#!/usr/bin/ruby -w
#
# $Id: item_lookup1,v 1.5 2008/04/11 19:24:24 ianmacd Exp $
require 'amazon/aws'
require 'amazon/aws/search'
include Amazon::AWS
include Amazon::AWS::Search
# Example of a batch operation, using the ASIN as the shared ID.
#
# The MerchantId restriction is to ensure that we retrieve only items that
# are for sale by Amazon. This is important when we later want to retrieve the
# availability status.
#
il = ItemLookup.new( 'ASIN', { 'ItemId' => 'B000AE4QEC',
'MerchantId' => 'Amazon' },
{ 'ItemId' => 'B000051WBE',
'MerchantId' => 'Amazon' } )
# You can have multiple response groups.
#
rg = ResponseGroup.new( 'Medium', 'Offers', 'Reviews' )
req = Request.new
req.locale = 'uk'
resp = req.search( il, rg )
item_sets = resp.item_lookup_response[0].items
item_sets.each do |item_set|
item_set.item.each do |item|
attribs = item.item_attributes[0]
puts attribs.label
if attribs.list_price
puts attribs.title, attribs.list_price[0].formatted_price
end
# Availability has become a cumbersome thing to retrieve in AWSv4.
#
puts 'Availability: %s' %
[ item.offers[0].offer[0].offer_listing[0].availability ]
puts 'Average rating: %s' % [ item.customer_reviews[0].average_rating ]
puts 'Reviewed by %s customers.' %
[ item.customer_reviews[0].total_reviews ]
puts 'Customers said:'
item.customer_reviews[0].review.each do |review|
puts ' %s (%s votes)' % [ review.summary, review.total_votes ]
end
puts
end
end
Jump to Line
Something went wrong with that request. Please try again.