class SimpleShipping::Ups::Client

Abstract class for all UPS clients. The problem with UPS is that its WSDL imports schemas. However schema imports are not supported by Savon as by v.2.1.0. See: github.com/savonrb/wasabi/issues/1 Because of this we have to manually:

1. Assign additional namespaces
2. Switch to :qualified :elemen_form_default
  (to have all requests elements prepended with namespace
   if its namespace is not specified explicitly)
3. Explicitly prepend namespace to all elements which not belong to WSDL target namespace
   i.e. UPSSecurity, Request/RequestOptions etc

Protected Instance Methods

client_options(options = {}) click to toggle source

@param [Hash] options Savon client options

# File lib/simple_shipping/ups/client.rb, line 16
def client_options(options = {})
  super.deep_merge(
    :element_form_default => :qualified,
    :namespaces => {
      'xmlns:upss'   => "http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0",
      'xmlns:common' => "http://www.ups.com/XMLSchema/XOLTWS/Common/v1.0",
    },
    :soap_header => soap_header
  )
end
soap_header() click to toggle source

@return [Hash] of SOAP envelope header contents

# File lib/simple_shipping/ups/client.rb, line 29
def soap_header
  {
    'upss:UPSSecurity' => {
      'upss:UsernameToken' => {
        'upss:Username' => @credentials.username,
        'upss:Password' => @credentials.password,
        :order!         => ['upss:Username', 'upss:Password']
      },
      'upss:ServiceAccessToken' => {
        'upss:AccessLicenseNumber' => @credentials.access_license_number
      },
      :order! => ['upss:UsernameToken', 'upss:ServiceAccessToken']
    }
  }
end