class SimpleShipping::Ups::ShipClient

Required credentials:

Usage

client = SimpleShipping::Ups::ShipClient.new(:username              => "USER NAME",
                                           :password              => "PASSWORD",
                                           :access_license_number => "LICENSE NUMBER")
client.request(shipper, recipient, package) # => #<SimpleShipping::Ups::Response ...>

Public Instance Methods

ship_accept_request(shipment_digest, options = {}) click to toggle source

Perform shipping accept request.

# File lib/simple_shipping/ups/ship_client.rb, line 42
def ship_accept_request(shipment_digest, options = {})
  request  = ShipAcceptRequest.new(@credentials, shipment_digest, options)
  execute(request)
end
ship_confirm_request(shipper, recipient, package, options = {}) click to toggle source

Send shipment confirmation request.

# File lib/simple_shipping/ups/ship_client.rb, line 34
def ship_confirm_request(shipper, recipient, package, options = {})
  shipment = create_shipment(shipper, recipient, package, options)
  request  = ShipConfirmRequest.new(@credentials, shipment, options)
  execute(request)
end
shipment_request(shipper, recipient, package, options = {}) click to toggle source

@param shipper [::SimpleShipping::Party] @param recipient [::SimpleShipping::Party] @param package [::SimpleShipping::Package] @param options [Hash] ({})

@return [::SimpleShipping::ShipmentResponse]

@raise [::SimpleShipping::RequestError] in case of SOAP errors

# File lib/simple_shipping/ups/ship_client.rb, line 27
def shipment_request(shipper, recipient, package, options = {})
  shipment = create_shipment(shipper, recipient, package, options)
  request  = ShipmentRequest.new(@credentials, shipment, options)
  execute(request)
end

Protected Instance Methods

client_options(options = {}) click to toggle source

@param [Hash] options Savon client options

# File lib/simple_shipping/ups/ship_client.rb, line 48
def client_options(options = {})
  super.deep_merge(
    :namespaces => {
      # Savon parses have WSDL instead of XMLSchema which is not accepted by UPS
      # So we have to again set namespace explicitly :( -- aignatev 20130204
      'xmlns:ship' => "http://www.ups.com/XMLSchema/XOLTWS/Ship/v1.0"
    }
  )
end

Private Instance Methods

execute(request) click to toggle source

Perform ShipmentRequest to UPS service.

# File lib/simple_shipping/ups/ship_client.rb, line 61
def execute(request)
  savon_response = @client.call(request.type, :message => request.body)
  log_response(savon_response)
  request.response(savon_response)
rescue Savon::SOAPFault => e
  raise SimpleShipping::RequestError.new(e)
end