<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>TODO.txt</filename>
    </added>
    <added>
      <filename>examples/item.rb</filename>
    </added>
    <added>
      <filename>spec/fixtures/item_search_harry_potter.xml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,6 +3,7 @@ License.txt
 Manifest.txt
 README.txt
 Rakefile
+TODO.txt
 config/hoe.rb
 config/requirements.rb
 lib/aaws.rb</diff>
      <filename>Manifest.txt</filename>
    </modified>
    <modified>
      <diff>@@ -5,4 +5,4 @@ require 'pp'
 config = YAML::load(open(ENV['HOME'] + '/.aaws'))
 
 AAWS::Base.establish_connection(config[:access_key])
-pp AAWS::Book.search(:title =&gt; 'Ruby on Rails')
\ No newline at end of file
+pp AAWS::Book.search(:title =&gt; 'Ruby on Rails')</diff>
      <filename>examples/book.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,6 @@
 $:.unshift File.dirname(__FILE__)
 
-# http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&amp;AWSAccessKeyId=[ID]&amp;Operation=ItemSearch&amp;SearchIndex=Books&amp;Title=Harry%20Potter&amp;Version=2008-03-03
-# Operation=ItemSearch&amp;SearchIndex=Books&amp;Title=Harry%20Potter&amp;Version=2008-03-03
-
+require 'ostruct'
 require 'rubygems'
 gem 'activesupport', '&gt;= 2.0.2'
 require 'activesupport'</diff>
      <filename>lib/aaws.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,9 +1,29 @@
 module AAWS
+  class SearchResults &lt; OpenStruct; end
+  
   class Item &lt; Base
     @default_params.update :operation =&gt; 'ItemSearch'
     
+    # just do an AAWS::Item.search(:title =&gt; 'ruby on rails').inspect to see the methods
     def self.search(options={})
-      get(options)
+      doc = parse(get(options))
+      items = (doc/'Item').inject([]) { |collection, item| collection &lt;&lt; new_from_element(item) }
+      SearchResults.new(:items =&gt; items)
+    end
+    
+    def self.new_from_element(element)
+      obj = OpenStruct.new
+      obj.asin = element.at('ASIN').innerHTML
+      obj.url = element.at('DetailPageURL').innerHTML
+      
+      # auto create methods for each of the item attributes
+      element.at('ItemAttributes').children.each do |child|
+        if child.respond_to?(:stag)
+          attr = child.stag.name.underscore
+          obj.send(&quot;#{attr}=&quot;, child.innerHTML) unless %w[asin url].include?(attr)
+        end        
+      end
+      obj
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/aaws/item.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,11 +5,12 @@ describe AAWS::Book do
     AAWS::Book.default_params.has_key?(:search_index).should == true
   end
   
-  it &quot;should return a collection of book objects when searching&quot; do
-    AAWS::Base.establish_connection('blah')
-    xml = open(File.dirname(__FILE__) + '/fixtures/book_search_ruby_on_rails.xml').read
-    AAWS::Connection.should_receive(:get).and_return(xml)
-    books = AAWS::Book.search(:title =&gt; 'Ruby on Rails')
-    
-  end
+  # TODO: implement this after item search works
+  # it &quot;should return a collection of book objects when searching&quot; do
+  #   AAWS::Base.establish_connection('blah')
+  #   xml = open(File.dirname(__FILE__) + '/fixtures/book_search_ruby_on_rails.xml').read
+  #   AAWS::Connection.should_receive(:get).and_return(xml)
+  #   books = AAWS::Book.search(:title =&gt; 'Ruby on Rails')
+  #   
+  # end
 end
\ No newline at end of file</diff>
      <filename>spec/aaws_book_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,4 +4,42 @@ describe AAWS::Item do
   it &quot;should have operation default param&quot; do
     AAWS::Item.default_params.has_key?(:operation).should == true
   end
+  
+  describe &quot;search results&quot; do
+    before(:each) do
+      AAWS::Base.establish_connection('blah')
+      xml = open(File.dirname(__FILE__) + '/fixtures/item_search_harry_potter.xml').read
+      AAWS::Item.should_receive(:get).and_return(xml)
+      @result = AAWS::Item.search(:title =&gt; 'Harry Potter')
+      @item = @result.items.first
+    end
+    
+    it &quot;should have asin&quot; do
+      @item.asin.should == '0545010225'
+    end
+    
+    it &quot;should have url&quot; do
+      @item.url.should == 'http://www.amazon.com/gp/redirect.html%3FASIN=0545010225%26tag=ws%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/Harry-Potter-Deathly-Hallows-Book/dp/0545010225%253FSubscriptionId=13BGQE8Q6AKCRYPHG0G2'
+    end
+    
+    it &quot;should have author&quot; do
+      @item.author.should == 'J. K. Rowling'
+    end
+    
+    it &quot;should have creator&quot; do
+      @item.creator.should == 'Mary GrandPr\303\251'
+    end
+    
+    it &quot;should have manufacturer&quot; do
+      @item.manufacturer.should == 'Arthur A. Levine Books'
+    end
+    
+    it &quot;should have product_group&quot; do
+      @item.product_group.should == 'Book'
+    end
+    
+    it &quot;should have title&quot; do
+      @item.title.should == 'Harry Potter and the Deathly Hallows (Book 7)'
+    end
+  end  
 end
\ No newline at end of file</diff>
      <filename>spec/aaws_item_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,7 +15,7 @@
 			&lt;/Argument&gt;
 			&lt;Argument Name=\&quot;Operation\&quot; Value=\&quot;ItemSearch\&quot;&gt;
 			&lt;/Argument&gt;
-			&lt;Argument Name=\&quot;AWSAccessKeyId\&quot; Value=\&quot;13BGQE8Q6AKCRYPHG0G2\&quot;&gt;
+			&lt;Argument Name=\&quot;AWSAccessKeyId\&quot; Value=\&quot;dontbeaswoosh\&quot;&gt;
 			&lt;/Argument&gt;
 		&lt;/Arguments&gt;
 		&lt;RequestProcessingTime&gt;0.064924955368042&lt;/RequestProcessingTime&gt;</diff>
      <filename>spec/fixtures/book_search_ruby_on_rails.xml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8a95d8eccdbf362dfcc4f07f380101b2e982b644</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/aaws/commit/0f713c2ea349423f00117cf14aa66def05b702a3</url>
  <id>0f713c2ea349423f00117cf14aa66def05b702a3</id>
  <committed-date>2008-06-01T12:01:30-07:00</committed-date>
  <authored-date>2008-06-01T12:01:30-07:00</authored-date>
  <message>got item search and book search flexibly working at requesting and turning xml into objects</message>
  <tree>f1dab264adba1b1cf47905d2e3844d4b14649730</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
