This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| 41134082 » | jnunemaker | 2008-12-06 | 1 | require 'rubygems' | |
| 2 | require 'activesupport' | ||||
| 3 | |||||
| fe18cff2 » | jnunemaker | 2008-07-28 | 4 | dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) | |
| 5 | require File.join(dir, 'httparty') | ||||
| 6 | require 'pp' | ||||
| 7 | config = YAML::load(File.read(File.join(ENV['HOME'], '.aaws'))) | ||||
| 8 | |||||
| 9 | module AAWS | ||||
| 10 | class Book | ||||
| 11 | include HTTParty | ||||
| 12 | base_uri 'http://ecs.amazonaws.com' | ||||
| 13 | default_params :Service => 'AWSECommerceService', :Operation => 'ItemSearch', :SearchIndex => 'Books' | ||||
| 14 | |||||
| 15 | def initialize(key) | ||||
| 16 | self.class.default_params :AWSAccessKeyId => key | ||||
| 17 | end | ||||
| 18 | |||||
| 19 | def search(options={}) | ||||
| 20 | raise ArgumentError, 'You must search for something' if options[:query].blank? | ||||
| aafde867 » | jnunemaker | 2008-07-28 | 21 | ||
| 06c04631 » | jnunemaker | 2008-07-28 | 22 | # amazon uses nasty camelized query params | |
| fe18cff2 » | jnunemaker | 2008-07-28 | 23 | options[:query] = options[:query].inject({}) { |h, q| h[q[0].to_s.camelize] = q[1]; h } | |
| aafde867 » | jnunemaker | 2008-07-28 | 24 | ||
| 25 | # make a request and return the items (NOTE: this doesn't handle errors at this point) | ||||
| fe18cff2 » | jnunemaker | 2008-07-28 | 26 | self.class.get('/onca/xml', options)['ItemSearchResponse']['Items'] | |
| 27 | end | ||||
| 28 | end | ||||
| 29 | end | ||||
| 30 | |||||
| 31 | aaws = AAWS::Book.new(config[:access_key]) | ||||
| 32 | pp aaws.search(:query => {:title => 'Ruby On Rails'}) | ||||








