Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update README

  • Loading branch information...
commit dda4efee03aa1539c943e683650c79c871ff5c95 1 parent e2e7c87
@hakanensari authored
Showing with 31 additions and 20 deletions.
  1. +31 −20 README.md
View
51 README.md
@@ -9,58 +9,69 @@ Advertising API] [5].
## Installation
-Add to your Gemfile.
+Add to your Gemfile:
gem 'vacuum'
-## Usage
+## Configuration
-Set up a request.
+Set up a locale:
- require "vacuum"
+ Vacuum.configure :us do |c|
+ c.key = 'a key'
+ c.secret = 'a secret'
+ c.tag = 'a tag'
+ end
- req = Vacuum["us"]
+## The Request
- req.configure do |c|
- c.key = AMAZON_KEY
- c.secret = AMAZON_SECRET
- c.tag = AMAZON_ASSOCIATE_TAG
- end
+Create a request for the above locale:
+
+ req = Vacuum.new(:us)
-Search for something.
+Search for something:
req << { :operation => 'ItemSearch',
:search_index => 'All',
:keywords => 'George Orwell' }
res = request.get
-Or use a shorthand.
+The following shorthand accomplishes the same search:
res = req.search('George Orwell')
-Customise your request.
+Customise your request:
res = req.search('Books', :response_group => 'ItemAttributes',
:power => 'George Orwell'
-For a reference of available methods and syntax, [read here] [6].
+For all available methods and syntax, [read here] [6].
+
+# The Response
+
+Check if the response is valid:
-Consume the entire response.
+ res.valid?
+
+While it sounds quirky, a valid response may contain errors. Check for
+those as well:
+
+ res.has_errors?
+
+Consume the entire response as a hash:
res.to_hash
-Quickly drop down to a particular node.
+Preferably, drop down to a particular node and consume the relevant
+bits and pieces you need:
res.each('Item') do |item|
- puts item['ASIN']
+ # item['ASIN']
end
-[Please see the project page] [7] for further detail.
-
[1]: https://github.com/hakanensari/vacuum/blob/master/vacuum.png?raw=true
[2]: https://secure.travis-ci.org/hakanensari/vacuum.png
[3]: http://travis-ci.org/hakanensari/vacuum
[4]: http://nokogiri.org/
[5]: https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html
[6]: https://github.com/hakanensari/vacuum/blob/master/lib/vacuum/operations.rb
-[7]: http://code.papercavalier.com/amazon_product/
Please sign in to comment.
Something went wrong with that request. Please try again.