<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -70,7 +70,7 @@ module Abebooks4r
 				raise Abebooks4r::RequestError, &quot;HTTP Response: #{res.code} #{res.message}&quot;
 			end
 			log &quot;Response text: #{res.body}&quot;
-			Response.new(res)
+			Response.new(res.body)
 		end
 		
 		
@@ -100,10 +100,21 @@ module Abebooks4r
 			def error_code
 				#Element.get(@doc, &quot;error/code&quot;)
 			end
-      
-			# Return error message.
-			def is_success?
-				     	      	      
+			
+			# Return an array of Abebooks4r::Element item objects.
+			def books
+				unless @books
+					@books = (@doc/&quot;book&quot;).collect {|item| Element.new(item)}
+				end
+				@books
+			end
+			
+			# Return total results.
+			def total_results
+				unless @total_results
+					@total_results = (@doc/&quot;resultcount&quot;).inner_html.to_i
+				end
+				@total_results		     	      	      
 			end     				                          
 		end
 		
@@ -125,9 +136,109 @@ module Abebooks4r
 		def self.prepare_url(params)
 			params = params.merge(self.options)
 			url = URI.parse(&quot;http://search2.abebooks.com/search?&quot; +
-    	    	    	params.to_a.collect{|item| item.first + &quot;=&quot; + CGI::escape(item.last) }.join(&quot;&amp;&quot;)
+				params.to_a.collect{|item| item.first.id2name + &quot;=&quot; + CGI::escape(item.last) }.join(&quot;&amp;&quot;)
           		)
           		return url
 		end	
-	end	
+	end
+	
+	# Internal wrapper class to provide convenient method to access Hpricot element value.
+	class Element
+	
+		# Pass Hpricot::Elements object
+		def initialize(element)
+			@element = element
+		end
+
+		# Returns Hpricot::Elments object    
+		def elem
+			@element
+		end
+    
+		# Find Hpricot::Elements matching the given path. Example: element/&quot;author&quot;.
+		def /(path)
+			elements = @element/path
+			return nil if elements.size == 0
+			elements
+		end
+    
+		# Find Hpricot::Elements matching the given path, and convert to Abebooks4r::Element.
+		# Returns an array Abebooks4r::Elements if more than Hpricot::Elements size is greater than 1.
+		def search_and_convert(path)
+			elements = self./(path)
+			return unless elements
+			elements = elements.map{|element| Element.new(element)}
+			return elements.first if elements.size == 1
+			elements
+		end
+
+		# Get the text value of the given path, leave empty to retrieve current element value.
+		def get(path='')
+			Element.get(@element, path)
+		end
+    
+		# Get the unescaped HTML text of the given path.
+		def get_unescaped(path='')
+			Element.get_unescaped(@element, path)
+		end
+    
+		# Get the array values of the given path.
+		def get_array(path='')
+			Element.get_array(@element, path)
+		end
+
+		# Get the children element text values in hash format with the element names as the hash keys.
+		def get_hash(path='')
+			Element.get_hash(@element, path)
+		end
+
+		# Similar to #get, except an element object must be passed-in.
+		def self.get(element, path='')
+			return unless element
+			result = element.at(path)
+			result = result.inner_html if result
+			result
+		end
+    
+		# Similar to #get_unescaped, except an element object must be passed-in.    
+		def self.get_unescaped(element, path='')
+			result = get(element, path)
+			CGI::unescapeHTML(result) if result
+		end
+
+		# Similar to #get_array, except an element object must be passed-in.
+		def self.get_array(element, path='')
+			return unless element
+      
+			result = element/path
+			if (result.is_a? Hpricot::Elements) || (result.is_a? Array)
+				parsed_result = []
+				result.each {|item|
+					parsed_result &lt;&lt; Element.get(item)
+				}
+				parsed_result
+			else
+				[Element.get(result)]
+			end
+        	end
+
+        	# Similar to #get_hash, except an element object must be passed-in.
+        	def self.get_hash(element, path='')
+        		return unless element
+    
+        		result = element.at(path)
+        		if result
+        			hash = {}
+        			result = result.children
+        			result.each do |item|
+        				hash[item.name.to_sym] = item.inner_html
+        			end 
+        			hash
+        		end
+        	end
+    
+        	def to_s
+        		elem.to_s if elem
+        	end
+        end	
 end	
\ No newline at end of file</diff>
      <filename>lib/abebooks4r.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,26 @@
 require 'helper'
 
 class TestAbebooks4r &lt; Test::Unit::TestCase
-  def test_something_for_real
-    flunk &quot;hey buddy, you should probably rename this file and start testing for real&quot;
-  end
+	
+	ABE_ACCESS_KEY = ''  
+  
+	raise &quot;Please specify set your ABE_ACCESS_KEY&quot; if ABE_ACCESS_KEY.empty?
+  
+  
+	Abebooks4r::Abe.configure do |options|    
+		options[:clientkey] = ABE_ACCESS_KEY  	  
+  	end
+	
+  	Abebooks4r::Abe.debug = false
+	
+	def test_abebooks_total_result_count
+		resp = Abebooks4r::Abe.search(:author =&gt; 'Brad Ediger', :title =&gt; 'Advanced Rails')
+		assert(resp.total_results == 43)
+	end
+	
+	def test_abebooks_book_object
+		resp = Abebooks4r::Abe.search(:author =&gt; 'Brad Ediger', :title =&gt; 'Advanced Rails')		
+		assert(resp.books.first.get('title') == 'Advanced Rails')
+		assert(resp.books.first.get('author') == 'Ediger, Brad')
+	end	
 end</diff>
      <filename>test/test_abebooks4r.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c3a45234fee62287ccb623f401b1c6d6b65a6a4a</id>
    </parent>
  </parents>
  <author>
    <name>Hasham</name>
    <email>hasham2@gmail.com</email>
  </author>
  <url>http://github.com/hasham2/abebooks4r/commit/19940f41372d84af4c3b1d64713a9752d15cda42</url>
  <id>19940f41372d84af4c3b1d64713a9752d15cda42</id>
  <committed-date>2009-10-23T04:51:29-07:00</committed-date>
  <authored-date>2009-10-23T04:51:29-07:00</authored-date>
  <message>Added some test and improved class with Element class added</message>
  <tree>5e9932ed6f095eb55c66c790f864d22847421712</tree>
  <committer>
    <name>Hasham</name>
    <email>hasham2@gmail.com</email>
  </committer>
</commit>
