Sha256: c60a2c5a1db8b75f98c5244c0b5c5d170a6af8b70997908efbd126d799bb7ea1

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

class Amazon::MWS::Authentication  
  
  class QueryString < String
    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
    
    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
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
amazon-mws-0.1.0 lib/amazon/mws/authentication/query_string.rb