Sha256: 5bb0073258ec6fcae30c25cc1fab0b1a29210368f58fdfb821a092fe4e37a95e

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

module Securetrading
  class Connection
    include HTTParty
    base_uri 'https://webservices.securetrading.net/xml'

    # headers after: http://www.securetrading.com/files/documentation/STPP-Web-Services-User-Guide.pdf
    headers(
      'Content-Type' => 'text/xml;charset=utf-8',
      'Accept-Encoding' => 'gzip',
      'Accept' => 'text/xml',
      'User-Agent' => 'Securetrading Ruby gem; '\
                      "version: #{Securetrading::VERSION}",
      'Connection' => 'close'
    )

    def post_with(xml, options = {})
      self.class.post('/', options.merge(body: xml, headers: dynamic_headers))
    end

    private

    def dynamic_headers
      { 'Authorization' => "Basic #{Securetrading.config.auth}" }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
securetrading-0.1.0 lib/securetrading/connection.rb