Class: ActiveMerchant::Shipping::UPS

Inherits:
Carrier show all
Defined in:
lib/active_shipping/shipping/carriers/ups.rb

Constant Summary collapse

TEST_URL =
'https://wwwcie.ups.com'
LIVE_URL =
'https://www.ups.com'
RESOURCES =
{
  :rates => 'ups.app/xml/Rate',
  :track => 'ups.app/xml/Track'
}
PICKUP_CODES =
HashWithIndifferentAccess.new({
  :daily_pickup => "01",
  :customer_counter => "03", 
  :one_time_pickup => "06",
  :on_call_air => "07",
  :suggested_retail_rates => "11",
  :letter_center => "19",
  :air_service_center => "20"
})
CUSTOMER_CLASSIFICATIONS =
HashWithIndifferentAccess.new({
  :wholesale => "01",
  :occasional => "03", 
  :retail => "04"
})
DEFAULT_CUSTOMER_CLASSIFICATIONS =

these are the defaults described in the UPS API docs, but they don’t seem to apply them under all circumstances, so we need to take matters into our own hands

Hash.new do |hash,key|
  hash[key] = case key.to_sym
  when :daily_pickup then :wholesale
  when :customer_counter then :retail
  else
    :occasional
  end
end
DEFAULT_SERVICES =
{
  "01" => "UPS Next Day Air",
  "02" => "UPS Second Day Air",
  "03" => "UPS Ground",
  "07" => "UPS Worldwide Express",
  "08" => "UPS Worldwide Expedited",
  "11" => "UPS Standard",
  "12" => "UPS Three-Day Select",
  "13" => "UPS Next Day Air Saver",
  "14" => "UPS Next Day Air Early A.M.",
  "54" => "UPS Worldwide Express Plus",
  "59" => "UPS Second Day Air A.M.",
  "65" => "UPS Saver",
  "82" => "UPS Today Standard",
  "83" => "UPS Today Dedicated Courier",
  "84" => "UPS Today Intercity",
  "85" => "UPS Today Express",
  "86" => "UPS Today Express Saver"
}
CANADA_ORIGIN_SERVICES =
{
  "01" => "UPS Express",
  "02" => "UPS Expedited",
  "14" => "UPS Express Early A.M."
}
MEXICO_ORIGIN_SERVICES =
{
  "07" => "UPS Express",
  "08" => "UPS Expedited",
  "54" => "UPS Express Plus"
}
EU_ORIGIN_SERVICES =
{
  "07" => "UPS Express",
  "08" => "UPS Expedited"
}
OTHER_NON_US_ORIGIN_SERVICES =
{
  "07" => "UPS Express"
}
EU_COUNTRY_CODES =
["GB", "AT", "BE", "BG", "CY", "CZ", "DK", "EE", "FI", "FR", "DE", "GR", "HU", "IE", "IT", "LV", "LT", "LU", "MT", "NL", "PL", "PT", "RO", "SK", "SI", "ES", "SE"]
US_TERRITORIES_TREATED_AS_COUNTRIES =
["AS", "FM", "GU", "MH", "MP", "PW", "PR", "VI"]
@@name =
"UPS"

Instance Attribute Summary

Attributes inherited from Carrier

#last_request, #test_mode

Instance Method Summary collapse

Methods inherited from Carrier

#initialize, #maximum_weight, #valid_credentials?

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Methods included from RequiresParameters

#requires!

Constructor Details

This class inherits a constructor from ActiveMerchant::Shipping::Carrier

Instance Method Details

#find_rates(origin, destination, packages, options = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 98

def find_rates(origin, destination, packages, options={})
  origin, destination = upsified_location(origin), upsified_location(destination)
  options = @options.merge(options)
  packages = Array(packages)
  access_request = build_access_request
  rate_request = build_rate_request(origin, destination, packages, options)
  response = commit(:rates, save_request(access_request + rate_request), (options[:test] || false))
  parse_rate_response(origin, destination, packages, response, options)
end

#find_tracking_info(tracking_number, options = {}) ⇒ Object



108
109
110
111
112
113
114
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 108

def find_tracking_info(tracking_number, options={})
  options = @options.update(options)
  access_request = build_access_request
  tracking_request = build_tracking_request(tracking_number, options)
  response = commit(:track, save_request(access_request + tracking_request), (options[:test] || false))
  parse_tracking_response(response, options)
end

#requirementsObject



94
95
96
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 94

def requirements
  [:key, :login, :password]
end