<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.0.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>Pluit Solutions</title>
	<link>http://www.pluitsolutions.com</link>
	<description>Web Development and Design, and Anything That Matters</description>
	<pubDate>Sun, 07 Mar 2010 18:21:49 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.0.1</generator>
	<language>en</language>
			<item>
		<title>Ruby Amazon E-Commerce REST Service API  &#160; (amazon-ecs)</title>
		<link>http://www.pluitsolutions.com/projects/amazon-ecs/</link>
		<comments>http://www.pluitsolutions.com/projects/amazon-ecs/#comments</comments>
		<pubDate>Thu, 07 Dec 2006 05:37:15 +0000</pubDate>
		<dc:creator>Herryanto Siatono</dc:creator>
		
	<category>General</category>
		<guid isPermaLink="false">http://www.pluitsolutions.com/amazon-ecs/</guid>
		<description><![CDATA[What is amazon-ecs?
A generic Amazon E-commerce REST API with configurable default options and method call options. It uses Hpricot to parse the XML output. Use Response and Element wrapper classes for easy access to the XML elements, and it supports ECS 4.0.
It is generic, so you can extend Amazon::Ecs to support the other not-implemented operations [...]]]></description>
			<content:encoded><![CDATA[<h4>What is amazon-ecs?</h4>
<p>A generic Amazon E-commerce REST API with configurable default options and method call options. It uses <a href="http://code.whytheluckystiff.net/hpricot/">Hpricot</a> to parse the XML output. Use Response and Element wrapper classes for easy access to the XML elements, and it supports ECS 4.0.</p>
<p>It is generic, so you can extend <code>Amazon::Ecs</code> to support the other not-implemented operations easily; and the response object just wraps around Hpricot element object, instead of providing one-to-one object/attributes to XML elements map.</p>
<p>With that, if in the future, there is a change in REST XML output structure, no changes will be required on <code>amazon-ecs</code>, instead you just need to change your element path.</p>
<p>And if you love history, click <a href="http://www.pluitsolutions.com/2006/12/07/ruby-amazon-e-commerce-rest-services-api-amazon-ecs/">here</a>. </p>
<h4>Links</h4>
<ul>
<li><a href="http://github.com/jugend/amazon-ecs/tree/master">GitHub Repository</a></li>
<li><a href="http://rubyforge.org/projects/amazon-ecs/">Rubyforge Home</a></li>
<li><a href="http://amazon-ecs.rubyforge.org/doc">Rdoc Documentation</a></li>
<li><a href="http://rubyforge.org/frs/?group_id=2718">Download</a></li>
</ul>
<h4>Installation</h4>
<p><pre>$ gem install amazon-ecs</pre></p>
<h4>Example</h4>
<p>Initiating a search request:<br />
<pre>
require 'amazon/ecs'

# default options; will be camelized and converted 
# to REST request parameters.
Amazon::Ecs.options = {:aWS_access_key_id =&gt; [your access key]}
res = Amazon::Ecs.item_search('ruby')

# or you can provide additional options
res = Amazon::Ecs.item_search('ruby', :response_group =&gt; 'Medium', :sort =&gt; 'salesrank')

# to search other Amazon UK
res = Amazon::Ecs.item_search('ruby', :country =&gt; :uk)
</pre></p>
<p>Retrieving common response values:<br />
<pre>
# some common response object methods
res.is_valid_request?
res.has_error?
res.error
res.total_pages
res.total_results
res.item_page
</pre></p>
<p>Retrieving items, and item attributes:<br />
<pre>
# traverse through each item (Amazon::Element)
res.items.each do |item|
  # retrieve string value using XML path
  item.get('asin')
  item.get('itemattributes/title')

  # or return Amazon::Element instance
  atts = item.search_and_convert('itemattributes')
  
  # get title as a string 
  atts.get('title')

  # get only returns the first element of an array
  atts.get('author')            # 'Author 1'

  # to retrieve an array
  atts.get_array('author')    # ['Author 1', 'Author 2', ...]

  # to retrieve a hash of children text values
  item.get_hash('smallimage') # {:url =&gt; ..., :width =&gt; ..., :height =&gt; ...}

  # '/' returns Hpricot::Elements array object, nil if not found
  reviews = item/'editorialreview'

  # traverse through Hpricot elements
  reviews.each do |review|
    # Getting a hash value out of Hpricot element
    Amazon::Element.get_hash(review) # [:source =&gt; ..., :content ==&gt; ...]

    # Or to get unescaped HTML values
    Amazon::Element.get_unescaped(review, 'source')
    Amazon::Element.get_unescaped(review, 'content')
        
    # Or this way
    el = Amazon::Element.new(review)
    el.get_unescaped('source')
    el.get_unescaped('content')  
  end
end
</pre></p>
<h4>Tip</h4>
<p>If you are on <code>irb</code> console, this trick helps to print a nicely formatted xml result:<br />
<pre>
require 'pp'
pp res = Amazon::Ecs.item_search('ruby').doc
</pre></p>
<h4>More Information</h4>
<p>Refer to <a href="http://docs.amazonwebservices.com/AWSEcommerceService/2005-10-05/index.html">Amazon ECS documentation</a> for more information on Amazon REST request parameters and XML output structure. </p>
<p>Or you can also get a sample of Amazon REST XML output from <a href="http://www.awszone.com/scratchpads/aws/ecs.us/index.aws">AWSZone.com</a>.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.pluitsolutions.com/projects/amazon-ecs/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
