Sha256: 4b69cb9215937fa6578697ecb1928b598d0fd3c2a6e424123e3ddb20d2338d3b
Contents?: true
Size: 966 Bytes
Versions: 2
Compression:
Stored size: 966 Bytes
Contents
require "base64" require "digest/md5" require "net/http" require "net/https" module MWS class Request DEFAULT_METHOD = :post def initialize(args) @method = args[:method] || DEFAULT_METHOD @path = args[:path] @endpoint = args[:endpoint] @headers = args[:headers] || {} @body = args[:body] || "" end def execute client = Net::HTTP.new(@endpoint, 443) client.use_ssl = true client.start do |https| case @method when :post then return https.post(@path, @body, headers) else raise ArgumentError, "#{@method} is unknown HTTP method" end end end private def headers { "Content-Type" => "text/xml", "Content-MD5" => Base64.encode64(Digest::MD5.digest(@body)), "User-Agent" => "MarketplaceWebService/#{MWS::VERSION} (Language=Ruby)", "Host" => @endpoint }.merge(@headers) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
marketplace_web_service-0.0.4 | lib/mws/request.rb |
marketplace_web_service-0.0.3 | lib/mws/request.rb |