Class Amazon::Search::Request
In: lib/amazon/search.rb
Parent: Object

This is the class around which most others in this library revolve. It contains the most common search methods and exception classes and is the class from which most others in the library inherit.

Methods

Classes and Modules

Class Amazon::Search::Request::ConfigError
Class Amazon::Search::Request::HTTPError
Class Amazon::Search::Request::LocaleError
Class Amazon::Search::Request::ModeError
Class Amazon::Search::Request::OfferError
Class Amazon::Search::Request::SearchError
Class Amazon::Search::Request::SortError
Class Amazon::Search::Request::TermError
Class Amazon::Search::Request::TokenError
Class Amazon::Search::Request::TypeError

Attributes

cache  [RW] 
config  [R] 
id  [R] 
locale  [R] 
token  [R] 

Public Class methods

Use this method to instantiate a basic search request object. dev_token is your AWS developer token, associate is your Associates ID, locale is the search locale in which you wish to work (us, uk, de, fr, ca or jp), cache is whether or not to utilise a response cache, and user_agent is the name of the client you wish to pass when performing calls to AWS. locale and cache can also be set later, if you wish to change the current behaviour.

For example:

 require 'amazon/search'
 include Amazon::Search

 r = Request.new('D23XFCO2UKJY82', 'foobar-20', 'us', false)

 # Do a bunch of things in the US locale with the cache off, then:
 #
 r.locale = 'uk'                      # Switch to the UK locale
 r.id = 'foobaruk-21'                 # Use a different Associates ID
                                      # in this locale.
 r.cache = Cache.new('/tmp/amazon')   # Start using a cache.

Note that reassigning the locale will dynamically and transparently set up a new HTTP connection to the correct server for that locale.

You may also put one or more of these parameters in a configuration file, which will be read in the order of /etc/amazonrc and ~/.amazonrc. This allows you to have a system configuration file, but still override some of its directives in a per user configuration file.

For example:

 dev_token = 'D23XFCO2UKJY82'
 associate = 'calibanorg-20'
 cache_dir = '/tmp/amazon/cache'

If you do not provide an Associate ID, the one belonging to the author of the Ruby/Amazon library will be used. If locale is not provided, us will be used. If cache == true, but you do not specify a cache_dir in a configuration file, /tmp/amazon will be used. However, this last convenience applies only when a Request object is instantiated. In other words, if you started off without a cache, but now wish to use one, you will need to directly assign a Cache object, as shown above.

If your environment requires the use a HTTP proxy server, you should define this in the environment variable $http_proxy. Ruby/Amazon will detect this and channel all outbound connections via your proxy server.

Public Instance methods

Search for a product by actor and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

E.g.

 resp = req.actor_search('ricky gervais', 'dvd', LITE, 1,
                         '+titlerank', 'ThirdPartyNew')

Search for a product by artist and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Search for a product by ASIN(s) and returns an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block. The offer_page parameter is ignored unless offerings is not nil.

Search for a product by director and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Return an Amazon::Search::Response of the products on a Listmania list. If a block is given, that Response’s @products will be passed to the block.

Search for a product by manufacturer and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Search for a product by browse node. The default of ‘1000’ is for best-selling books. Returns an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Search for a book, using a power search, and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Search for a product’s similar products and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Perform a text stream search and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Search for a product by UPC code(s) and return an Amazon::Search::Response. If a block is given, that Response’s @products will be passed to the block.

Return an Amazon::Search::Response of the products on a wishlist. If a block is given, that Response’s @products will be passed to the block.

[Validate]