Class: Fedex::Request::TrackingInformation
- Defined in:
- lib/fedex/request/tracking_information.rb
Constant Summary
Constants inherited from Base
Base::CLEARANCE_BROKERAGE_TYPE, Base::DROP_OFF_TYPES, Base::PACKAGING_TYPES, Base::PRODUCTION_URL, Base::RECIPIENT_CUSTOM_ID_TYPE, Base::SERVICE_TYPES, Base::TEST_URL
Instance Attribute Summary collapse
-
#package_id ⇒ Object
readonly
Returns the value of attribute package_id.
-
#package_type ⇒ Object
readonly
Returns the value of attribute package_type.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(credentials, options = {}) ⇒ TrackingInformation
constructor
A new instance of TrackingInformation.
- #process_request ⇒ Object
Constructor Details
#initialize(credentials, options = {}) ⇒ TrackingInformation
Returns a new instance of TrackingInformation.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fedex/request/tracking_information.rb', line 10 def initialize(credentials, ={}) requires!(, :package_type, :package_id) unless .has_key?(:tracking_number) @package_id = [:package_id] || .delete(:tracking_number) @package_type = [:package_type] || "TRACKING_NUMBER_OR_DOORTAG" @credentials = credentials # Optional @include_detailed_scans = [:include_detailed_scans] @uuid = [:uuid] @paging_token = [:paging_token] unless package_type_valid? raise "Unknown package type '#{package_type}'" end end |
Instance Attribute Details
#package_id ⇒ Object (readonly)
Returns the value of attribute package_id.
8 9 10 |
# File 'lib/fedex/request/tracking_information.rb', line 8 def package_id @package_id end |
#package_type ⇒ Object (readonly)
Returns the value of attribute package_type.
8 9 10 |
# File 'lib/fedex/request/tracking_information.rb', line 8 def package_type @package_type end |
Instance Method Details
#process_request ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/fedex/request/tracking_information.rb', line 27 def process_request api_response = self.class.post(api_url, :body => build_xml) puts api_response if @debug == true response = parse_response(api_response) if success?(response) = response[:track_reply][:track_details] Fedex::TrackingInformation.new() else = if response[:track_reply] response[:track_reply][:notifications][:message] else api_response["Fault"]["detail"]["fault"]["reason"] end rescue $1 raise RateError, end end |