Class: ActiveMerchant::Shipping::UPS
- 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', :shipment_confirm => 'ups.app/xml/ShipConfirm', :shipment_accept => 'ups.app/xml/ShipAccept', :void => 'ups.app/xml/Void' }
- 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 =
From en.wikipedia.org/w/index.php?title=European_Union&oldid=174718707 (Current as of November 30, 2007)
["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"]
- CREDIT_CARD_TYPES =
{ "American Express" => "01", "Discover" => "03", "MasterCard" => "04", "Optima" => "05", "VISA" => "06", "Bravo" => "07", "Diners Club" => "08" }
- @@name =
"UPS"
Instance Attribute Summary
Attributes inherited from Carrier
Instance Method Summary collapse
- #find_rates(origin, destination, packages, options = {}) ⇒ Object
- #find_tracking_info(tracking_number, options = {}) ⇒ Object
- #requirements ⇒ Object
- #shipment_accept_request(digest, options = {}) ⇒ Object
- #shipment_confirmation_request(carrier_service, packages, label_specification, options) ⇒ Object
- #void_shipment(identification_number, tracking_numbers = [], options = {}) ⇒ Object
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
Constructor Details
This class inherits a constructor from ActiveMerchant::Shipping::Carrier
Instance Method Details
#find_rates(origin, destination, packages, options = {}) ⇒ Object
111 112 113 114 115 116 117 118 119 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 111 def find_rates(origin, destination, packages, ={}) origin, destination = upsified_location(origin), upsified_location(destination) = @options.merge() packages = Array(packages) access_request = build_access_request rate_request = build_rate_request(origin, destination, packages, ) response = commit(:rates, save_request(access_request + rate_request), ([:test] || false)) parse_rate_response(origin, destination, packages, response, ) end |
#find_tracking_info(tracking_number, options = {}) ⇒ Object
121 122 123 124 125 126 127 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 121 def find_tracking_info(tracking_number, ={}) = @options.update() access_request = build_access_request tracking_request = build_tracking_request(tracking_number, ) response = commit(:track, save_request(access_request + tracking_request), ([:test] || false)) parse_tracking_response(response, ) end |
#requirements ⇒ Object
107 108 109 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 107 def requirements [:key, :login, :password] end |
#shipment_accept_request(digest, options = {}) ⇒ Object
138 139 140 141 142 143 144 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 138 def shipment_accept_request(digest, = {}) = @options.merge() access_request = "<?xml version='1.0' ?>" + build_access_request acceptance_request = "<?xml version='1.0' encoding='UTF-8' ?>" + build_shipment_acceptance_request(digest, ) response = commit(:shipment_accept, save_request(access_request + acceptance_request), ([:test] || false)) parse_shipment_accept_response(response, ) end |
#shipment_confirmation_request(carrier_service, packages, label_specification, options) ⇒ Object
129 130 131 132 133 134 135 136 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 129 def shipment_confirmation_request(carrier_service, packages, label_specification, ) = @options.merge() packages = Array(packages) access_request = "<?xml version='1.0' ?>" + build_access_request confirmation_request = "<?xml version='1.0' encoding='UTF-8' ?>" + build_confirmation_request(carrier_service, packages, label_specification, ) response = commit(:shipment_confirm, save_request(access_request + confirmation_request), ([:test] || false)) parse_shipment_confirm_response(response, ) end |
#void_shipment(identification_number, tracking_numbers = [], options = {}) ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'lib/active_shipping/shipping/carriers/ups.rb', line 146 def void_shipment(identification_number, tracking_numbers = [], = {}) = @options.merge() tracking_numbers = Array(tracking_numbers) access_request = "<?xml version='1.0' ?>" + build_access_request void_request = "<?xml version='1.0' encoding='UTF-8' ?>" + build_void_shipment_request(identification_number, tracking_numbers, ) response = commit(:void, save_request(access_request + void_request), ([:test] || false)) parse_void_response(response, ) end |