Class: Omniship::UPS
Constant Summary collapse
- TEST_URL =
'https://wwwcie.ups.com'
- LIVE_URL =
'https://onlinetools.ups.com'
- RESOURCES =
{ :rates => 'ups.app/xml/Rate', :track => 'ups.app/xml/Track', :shipconfirm => 'ups.app/xml/ShipConfirm', :shipaccept => 'ups.app/xml/ShipAccept', :shipvoid => 'ups.app/xml/Void', :valid_address => 'ups.app/xml/AV', :valid_address_street => 'ups.app/xml/XAV' }
- 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"]
- @@name =
"UPS"
Instance Attribute Summary
Attributes inherited from Carrier
Instance Method Summary collapse
- #accept_shipment(digest, options = {}) ⇒ Object
-
#create_shipment(origin, destination, packages, options = {}) ⇒ Object
Creating shipping functionality for UPS.
- #find_rates(origin, destination, packages, options = {}) ⇒ Object
- #find_tracking_info(tracking_number, options = {}) ⇒ Object
- #requirements ⇒ Object
- #validate_address(city, state, zip_code, country_code, options = {}) ⇒ Object
- #validate_address_street(address, city, state, zip_code, country_code, options = {}) ⇒ Object
- #void_shipment(ups_shipment_id, tracking_numbers = [], options = {}) ⇒ Object
Methods inherited from Carrier
#initialize, #maximum_weight, #valid_credentials?
Constructor Details
This class inherits a constructor from Omniship::Carrier
Instance Method Details
#accept_shipment(digest, options = {}) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/omniship/carriers/ups.rb', line 135 def accept_shipment(digest, ={}) [:test] = [:test].nil? ? true : [:test] access_request = build_access_request ship_accept_request = build_ship_accept(digest) response = commit(:shipaccept, save_request(access_request.gsub("\n", "") + ship_accept_request.gsub("\n", "")), [:test]) parse_ship_accept_response(response, ) end |
#create_shipment(origin, destination, packages, options = {}) ⇒ Object
Creating shipping functionality for UPS
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/omniship/carriers/ups.rb', line 123 def create_shipment(origin, destination, packages, ={}) @options = @options.merge() origin, destination = upsified_location(origin), upsified_location(destination) = @options.merge() [:test] = [:test].nil? ? true : [:test] packages = Array(packages) access_request = build_access_request ship_confirm_request = build_ship_confirm(origin, destination, packages, ) response = commit(:shipconfirm, save_request(access_request.gsub("\n", "") + ship_confirm_request.gsub("\n", "")), [:test]) parse_ship_confirm_response(origin, destination, packages, response, ) end |
#find_rates(origin, destination, packages, options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 111 |
# File 'lib/omniship/carriers/ups.rb', line 102 def find_rates(origin, destination, packages, ={}) origin, destination = upsified_location(origin), upsified_location(destination) = @options.merge() [:test] = [:test].nil? ? false : [:test] packages = Array(packages) access_request = build_access_request rate_request = build_rate_request(origin, destination, packages, ) response = commit(:rates, save_request(access_request.gsub("\n", "") + rate_request.gsub("\n", "")), [:test]) parse_rate_response(origin, destination, packages, response, ) end |
#find_tracking_info(tracking_number, options = {}) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/omniship/carriers/ups.rb', line 113 def find_tracking_info(tracking_number, ={}) = @options.update() [:test] = [:test].nil? ? false : [:test] access_request = build_access_request tracking_request = build_tracking_request(tracking_number, ) response = commit(:track, save_request(access_request.gsub("\n", "") + tracking_request.gsub("\n", "")), [:test]) # parse_tracking_response(response, options) end |
#requirements ⇒ Object
98 99 100 |
# File 'lib/omniship/carriers/ups.rb', line 98 def requirements [:key, :login, :password] end |
#validate_address(city, state, zip_code, country_code, options = {}) ⇒ Object
153 154 155 156 157 158 159 160 |
# File 'lib/omniship/carriers/ups.rb', line 153 def validate_address(city, state, zip_code, country_code, ={}) @options = @options.merge() access_request = build_access_request validate_address_request = build_valid_address_request(city,state,zip_code,country_code) [:test] = [:test].nil? ? true : [:test] response = commit(:valid_address, save_request(access_request.gsub("\n", "") + validate_address_request.gsub("\n", "")), [:test]) parse_ship_valid_address(response) end |
#validate_address_street(address, city, state, zip_code, country_code, options = {}) ⇒ Object
162 163 164 165 166 167 168 169 |
# File 'lib/omniship/carriers/ups.rb', line 162 def validate_address_street(address, city, state, zip_code, country_code, ={}) @options = @options.merge() access_request = build_access_request validate_address_street_request = build_valid_address_street_request(address,city,state,zip_code,country_code) [:test] = [:test].nil? ? true : [:test] response = commit(:valid_address_street, save_request(access_request.gsub("\n", "") + validate_address_street_request.gsub("\n", "")), [:test]) parse_ship_valid_address_street(response) end |
#void_shipment(ups_shipment_id, tracking_numbers = [], options = {}) ⇒ Object
143 144 145 146 147 148 149 150 151 |
# File 'lib/omniship/carriers/ups.rb', line 143 def void_shipment(ups_shipment_id, tracking_numbers = [], ={}) @options = @options.merge() = @options.merge() [:test] = [:test].nil? ? true : [:test] access_request = build_access_request ship_void_request = build_void_request(ups_shipment_id,tracking_numbers) response = commit(:shipvoid, save_request(access_request.gsub("\n", "") + ship_void_request.gsub("\n", "")), [:test]) parse_ship_void_response(response, ) end |