The gem is tested against 1.9.2, 1.9.1 and 1.8.7 (compatibility with Heroku-Bamboo-Stack) and runs smoothly with Rails 3.
gem install asin
Since Version 0.2.0 ASIN provides a Rails-Style configuration.
You can put this in a initializer (config/initializers/asin.rb):
ASIN::Configuration.configure do |config| config.secret = 'your-secret' config.key = 'your-key' end
The old configuration syntax is still valid:
require 'asin' include ASIN # use the configure method to setup your api credentials configure :secret => 'your-secret', :key => 'your-key'
# create an ASIN client client = ASIN.client # lookup an item with the amazon standard identification number (asin) item = client.lookup '1430218150' # have a look at the title of the item item.title => Learn Objective-C on the Mac (Learn Series) # search for any kind of stuff on amazon items = search 'Learn Objective-C' items.first.title => "Learn Objective-C on the Mac (Learn Series)" # access the internal data representation (Hashie::Mash) item.raw.ItemAttributes.ListPrice.FormattedPrice => $39.99
ASIN uses HTTPI as a HTTP-Client adapter. See the HTTPI documentation for how to configure different clients or the logger. As a default HTTPI uses httpclient so you should add that dependency to your project:
gem 'httpclient'
Have a look at the RDOC for this project, if you want further information.
For more information on the REST calls, have a look at the whole Amazon E-Commerce-API.
The code currently runs best on Ruby-1.9 due to encoding issues with the Amazon REST output (if YOU know how to backport this to 1.8.7, you are welcome!).