Class: Amazon::MWS::Authentication::QueryString

Inherits:
String show all
Defined in:
lib/amazon/mws/authentication/query_string.rb

Instance Method Summary collapse

Methods inherited from String

#camelize, #to_boolean, #underscore, #valid_utf8?

Constructor Details

#initialize(params = {}) ⇒ QueryString

Returns a new instance of QueryString.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/amazon/mws/authentication/query_string.rb', line 4

def initialize(params = {})
  query_params = {
    'AWSAccessKeyId'   => params[:access_key],
    'Marketplace'      => params[:marketplace_id],
    'Merchant'         => params[:merchant_id],
    'SignatureMethod'  => Signature::METHOD,
    'SignatureVersion' => Signature::VERSION,
    'Timestamp'        => Time.now.iso8601,
    'Version'          => Amazon::MWS::Authentication::VERSION
  }
  
  # Add any params that are passed in via uri before calculating the signature
  query_params = query_params.merge(params[:query_params] || {})
  # Calculate the signature
  query_params['Signature'] = Signature.new(query_params, params)
  
  self << formatted_querystring(query_params)
end

Instance Method Details

#formatted_querystring(query_params) ⇒ Object



23
24
25
# File 'lib/amazon/mws/authentication/query_string.rb', line 23

def formatted_querystring(query_params)
  query_params.collect { |key, value| [CGI.escape(key.to_s), CGI.escape(value.to_s)].join('=') }.join('&') # order doesn't matter for the actual request
end