Class: Vacuum::Request
Overview
An Amazon Product Advertising API request.
Constant Summary collapse
- BadLocale =
Class.new(ArgumentError)
- HOSTS =
{ 'BR' => 'webservices.amazon.com.br', 'CA' => 'webservices.amazon.ca', 'CN' => 'webservices.amazon.cn', 'DE' => 'webservices.amazon.de', 'ES' => 'webservices.amazon.es', 'FR' => 'webservices.amazon.fr', 'GB' => 'webservices.amazon.co.uk', 'IN' => 'webservices.amazon.in', 'IT' => 'webservices.amazon.it', 'JP' => 'webservices.amazon.co.jp', 'US' => 'webservices.amazon.com' }.freeze
- OPERATIONS =
%w( BrowseNodeLookup CartAdd CartClear CartCreate CartGet CartModify ItemLookup ItemSearch SimilarityLookup ).freeze
Instance Attribute Summary collapse
-
#associate_tag ⇒ Object
Returns the value of attribute associate_tag.
Instance Method Summary collapse
-
#configure(credentials) ⇒ Object
Configure the Amazon Product Advertising API request.
-
#initialize(locale = 'US', secure = false) ⇒ Request
constructor
Create a new request for given locale.
Constructor Details
#initialize(locale = 'US', secure = false) ⇒ Request
Create a new request for given locale.
locale - The String Product Advertising API locale (default: US). secure - Whether to use the secure version of the endpoint (default:
false)
Raises a Bad Locale error if locale is not valid.
50 51 52 53 |
# File 'lib/vacuum/request.rb', line 50 def initialize(locale = 'US', secure = false) host = HOSTS.fetch(locale) { raise BadLocale } @aws_endpoint = "#{secure ? 'https' : 'http' }://#{host}/onca/xml" end |
Instance Attribute Details
#associate_tag ⇒ Object
Returns the value of attribute associate_tag.
41 42 43 |
# File 'lib/vacuum/request.rb', line 41 def associate_tag @associate_tag end |
Instance Method Details
#configure(credentials) ⇒ Object
Configure the Amazon Product Advertising API request.
credentials - The Hash credentials of the API endpoint.
:aws_access_key_id - The String Amazon Web Services
(AWS) key.
:aws_secret_access_key - The String AWS secret.
:associate_tag - The String Associate Tag.
Returns self.
64 65 66 67 |
# File 'lib/vacuum/request.rb', line 64 def configure(credentials) credentials.each { |key, val| self.send("#{key}=", val) } self end |