lib/sucker/request.rb in sucker-1.4.0 vs lib/sucker/request.rb in sucker-1.4.1

- old
+ new

@@ -2,54 +2,56 @@ require 'openssl' require 'sucker/parameters' module Sucker - # A wrapper around the API request + # A wrapper around the API request. class Request HOSTS = { :us => 'ecs.amazonaws.com', :uk => 'ecs.amazonaws.co.uk', :de => 'ecs.amazonaws.de', :ca => 'ecs.amazonaws.ca', :fr => 'ecs.amazonaws.fr', :jp => 'ecs.amazonaws.jp' } - # Your Amazon associate tag + # The Amazon associate tag. attr_accessor :associate_tag - # Your AWS access key + # The Amazon Web Services access key. attr_accessor :key - # Amazon locale + # The Amazon locale. attr_accessor :locale - # Your AWS secret + # The Amazon Web Services secret. attr_accessor :secret - # Initializes a request object + # Initializes a request object. # + # Takes an optional hash of attribute and value pairs. + # # worker = Sucker.new( # :key => 'API KEY', # :secret => 'API SECRET') # def initialize(args={}) args.each { |k, v| send("#{k}=", v) } end - # Merges a hash into the existing parameters + # Merges a hash into the existing parameters. # # worker << { # 'Operation' => 'ItemLookup', # 'IdType' => 'ASIN', # 'ItemId' => '0816614024' } # def <<(hash) parameters.merge!(hash) end - # Performs a request and returns a response + # Performs a request and returns a response object. # # response = worker.get # def get response = Net::HTTP.start(host) do |http| @@ -58,16 +60,16 @@ end Response.new(response) end - # The parameters to query Amazon with + # The query parameters. def parameters @parameters ||= Parameters.new end - # Sets the Amazon API version + # Sets the Amazon API version. # # worker.version = '2010-06-01' # def version=(version) parameters['Version'] = version @@ -101,9 +103,9 @@ '%' + $1.unpack('H2' * $1.bytesize).join('%').upcase end end def host - HOSTS[locale] + HOSTS[locale.to_sym] end end end