Module: Amazonian
- Defined in:
- lib/amazonian.rb,
lib/amazonian/version.rb
Overview
This module is designed to allow easier querying of the Amazon Product Advertising API from within your Ruby or Rails applications.
Basic usage requires first calling Amazonian.setup to provide your Amazon AWS Key and Secret key for the module to use in querying the database.
Amazons internal product ids can be used to retrieve data from the API with Amazonian.asin.
Searching for products is done via Amazonian.search
Defined Under Namespace
Constant Summary collapse
- VERSION =
"0.2.0"- @@digest =
worker objects
OpenSSL::Digest::Digest.new('sha256')
- @@logger =
Logger.new(STDERR)
- @@patron =
Patron::Session.new
Class Method Summary collapse
-
.asin(asin, params = {}) ⇒ Amazonian::Item
Perform an ASIN (Amazon Standard Identification Number) lookup.
-
.search(query, params = {}) ⇒ Amazonian::Search
Perform a search query to the API.
-
.setup {|amazonian| ... } ⇒ Object
Configure the basic request parameters for Amazonian.
Class Method Details
.asin(asin, params = {}) ⇒ Amazonian::Item
Perform an ASIN (Amazon Standard Identification Number) lookup.
84 85 86 87 88 |
# File 'lib/amazonian.rb', line 84 def self.asin(asin, params={}) params = params.merge :Operation => :ItemLookup, :ItemId => asin xml = self.call params Item.new xml['ItemLookupResponse']['Items']['Item'] end |
.search(query, params = {}) ⇒ Amazonian::Search
Perform a search query to the API. This is basically the same thing as searching with the Amazon website.
104 105 106 107 108 109 110 111 112 |
# File 'lib/amazonian.rb', line 104 def self.search(query, params={}) params = params.merge :Operation => :ItemSearch, :Keywords => query params[:SearchIndex] = @default_search if params[:SearchIndex].nil? xml = self.call params Search.new xml['ItemSearchResponse'] end |
.setup {|amazonian| ... } ⇒ Object
Configure the basic request parameters for Amazonian.
Pass in a block with 1 parameter and modify configuration variables from there.
68 69 70 |
# File 'lib/amazonian.rb', line 68 def self.setup yield self if block_given? end |