Class: Vacuum::Request
Overview
An Amazon Product Advertising API request.
Constant Summary collapse
- BadLocale =
Class.new(ArgumentError)
- LATEST_VERSION =
'2013-08-01'- HOSTS =
{ 'AU' => 'webservices.amazon.com.au', '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', 'MX' => 'webservices.amazon.com.mx', 'TR' => 'webservices.amazon.com.tr', 'US' => 'webservices.amazon.com' }.freeze
Instance Attribute Summary collapse
-
#associate_tag ⇒ Object
Returns the value of attribute associate_tag.
-
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
-
#version ⇒ Object
Returns the API version.
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.
60 61 62 63 64 |
# File 'lib/vacuum/request.rb', line 60 def initialize(locale = 'US', secure = false) locale = 'GB' if locale == 'UK' 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.
50 51 52 |
# File 'lib/vacuum/request.rb', line 50 def associate_tag @associate_tag end |
#subscription_id ⇒ Object
Returns the value of attribute subscription_id.
50 51 52 |
# File 'lib/vacuum/request.rb', line 50 def subscription_id @subscription_id end |
#version ⇒ Object
Returns the API version.
82 83 84 |
# File 'lib/vacuum/request.rb', line 82 def version @version || LATEST_VERSION 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.
:aws_version - The String AWS version.
Returns self.
76 77 78 79 |
# File 'lib/vacuum/request.rb', line 76 def configure(credentials) credentials.each { |key, val| send("#{key}=", val) } self end |