README.markdown in sucker-1.0.0.beta.1 vs README.markdown in sucker-1.0.0.beta.2
- old
+ new
@@ -1,11 +1,11 @@
Sucker
======
-Sucker is a Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on cURL and the Nokogiri implementation of the XML Mini module in Active Support. It is blazing fast and supports __the entire API__.
+Sucker is a Ruby wrapper to the [Amazon Product Advertising API](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html). It runs on [curb](http://github.com/taf2/curb) and the Nokogiri implementation of the XML Mini module in Active Support. It is blazing fast and supports __the entire API__.
-![Sucker](http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/FEMA_-_32011_-_FEMA_Joint_Field_Office_%28JFO%29_preparation_in_Ohio.jpg/540px-FEMA_-_32011_-_FEMA_Joint_Field_Office_%28JFO%29_preparation_in_Ohio.jpg)
+![Sucker](http://upload.wikimedia.org/wikipedia/commons/thumb/f/f8/FEMA_-_32011_-_FEMA_Joint_Field_Office_%28JFO%29_preparation_in_Ohio.jpg/480px-FEMA_-_32011_-_FEMA_Joint_Field_Office_%28JFO%29_preparation_in_Ohio.jpg)
Examples
--------
Set up a worker.
@@ -13,62 +13,57 @@
worker = Sucker.new(
:locale => "us",
:key => "API KEY",
:secret => "API SECRET")
-Optionally, fiddle with cURL. Say you want to query Amazon through a different network interface:
+Prep a request.
- worker.curl { |c| c.interface = "eth0:0" }
-
-Set up a request.
-
asin_batch = %w{
0816614024 0143105825 0485113600 0816616779 0942299078
0816614008 144006654X 0486400360 0486417670 087220474X }
worker << {
"Operation" => "ItemLookup",
"IdType" => "ASIN",
"ItemId" => asin_batch,
"ResponseGroup" => ["ItemAttributes", "OfferFull"] }
-Hit Amazon.
+Perform the request.
response = worker.get
-View the internals of the response object.
+Debug.
- p response.code,
- response.time,
- response.body,
- response.xml
+ if response.valid?
+ p response.code,
+ response.time,
+ response.body,
+ response.xml,
+ response.to_hash
+ end
-Confirm response is valid.
+Say you performed an item lookup. Iterate over all items and errors.
- response.valid?
+ response.node("Item").each { |item| ... }
+ response.node("Error").each { |error| ... }
-Cast response as a hash:
+Perform a new request in a more DSL-y way.
- pp response.to_hash
-
-Grab a node:
-
- response.node("Item"),
- response.node("Error")
-
-Fetch another ASIN in a more DSL-y way.
-
worker << { "ItemId" => "0486454398" }
- pp worker.get.node("Item")
+ worker.get.node("Item").each { |item| ... }
Repeat ad infinitum.
-Check the [integration specs](http://github.com/papercavalier/sucker/tree/master/spec/integration/) for more examples and then dive into the [API docs](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html).
+Check the [integration specs](http://github.com/papercavalier/sucker/tree/master/spec/integration/) for more examples. In particullar, see [twenty items](http://github.com/papercavalier/sucker/tree/master/spec/integration/twenty_items_spec.rb) and [multiple locales](http://github.com/papercavalier/sucker/tree/master/spec/integration/multiple_locales_spec.rb) for advanced usage.
+Finally, dive into the [API docs](https://affiliate-program.amazon.co.uk/gp/advertising/api/detail/main.html) to construct your own queries.
+
Stubbing
--------
-Use [VCR](http://github.com/myronmarston/vcr). [This](http://github.com/papercavalier/sucker/blob/master/spec/support/sucker.rb) is my RSpec helper.
+Use [VCR](http://github.com/myronmarston/vcr) to stub your requests. [This file](http://github.com/papercavalier/sucker/blob/master/spec/support/vcr.rb) should help you set up VCR with RSpec.
+Don't match requests on URI. The parameters include a timestamp that results in each URI being unique.
+
Compatibility
-------------
-Specs pass against Ruby 1.8.7 and 1.9.2.
+Specs pass against Ruby 1.8.7, Ruby 1.9.2, and Rubinius 1.1.