Class: Trackerific::UPS
Overview
Provides package tracking support for UPS.
Instance Method Summary (collapse)
-
- (Array) required_options
The required options for tracking a UPS package are :key, :user_id, and :password.
-
- (Trackerific::Details) track_package(package_id)
Tracks a UPS package.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Trackerific::Base
Instance Method Details
- (Array) required_options
The required options for tracking a UPS package are :key, :user_id, and :password.
19 20 21 |
# File 'lib/ups.rb', line 19 def [:key, :user_id, :password] end |
- (Trackerific::Details) track_package(package_id)
Tracks a UPS package. A Trackerific::Error is raised when a package cannot be tracked.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/ups.rb', line 26 def track_package(package_id) super # connect to UPS via HTTParty http_response = self.class.post('/Track', :body => build_xml_request) # throw any HTTP errors http_response.error! unless http_response.code == 200 # Check the response for errors, return a Trackerific::Error, or parse # the response from UPS and return a Trackerific::Details case http_response['TrackResponse']['Response']['ResponseStatusCode'] when "0" then raise Trackerific::Error, parse_error_response(http_response) when "1" then return parse_success_response(http_response) else raise Trackerific::Error, "Invalid response code returned from server." end end |