Sha256: 74b2c8761735b7e9222182abf70d6f26c0efca8b82be5305a556e189e50c65d0

Contents?: true

Size: 1.51 KB

Versions: 6

Compression:

Stored size: 1.51 KB

Contents

require 'fedex/tracking_information/event'

module Fedex
  class TrackingInformation
    PACKAGE_IDENTIFIER_TYPES = %w{
      BILL_OF_LADING
      COD_RETURN_TRACKING_NUMBER
      CUSTOMER_AUTHORIZATION_NUMBER
      CUSTOMER_REFERENCE
      DEPARTMENT
      FREE_FORM_REFERENCE
      GROUND_INTERNATIONAL
      GROUND_SHIPMENT_ID
      GROUP_MPS
      INVOICE
      JOB_GLOBAL_TRACKING_NUMBER
      ORDER_GLOBAL_TRACKING_NUMBER
      ORDER_TO_PAY_NUMBER
      PARTNER_CARRIER_NUMBER
      PART_NUMBER
      PURCHASE_ORDER
      RETURN_MATERIALS_AUTHORIZATION
      RETURNED_TO_SHIPPER_TRACKING_NUMBER
      TRACKING_CONTROL_NUMBER
      TRACKING_NUMBER_OR_DOORTAG
      TRANSPORTATION_CONTROL_NUMBER
      SHIPPER_REFERENCE
      STANDARD_MPS
    }

    attr_reader :tracking_number, :signature_name, :service_type, :status,
                :delivery_at, :events, :unique_tracking_number, :details

    def initialize(details = {})
      @details = details

      @tracking_number        = details[:tracking_number]
      @unique_tracking_number = details[:tracking_number_unique_identifier]
      @signature_name         = details[:delivery_signature_name]
      @service_type           = details[:service_type]
      @status                 = details[:status_description]

      if details.has_key?(:actual_delivery_timestamp)
        @delivery_at = Time.parse(details[:actual_delivery_timestamp])
      end

      @events = [details[:events]].flatten.compact.map do |event_details|
        Event.new(event_details)
      end
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
fedex-3.6.1 lib/fedex/tracking_information.rb
fedex-3.6.0 lib/fedex/tracking_information.rb
fedex-3.4.0 lib/fedex/tracking_information.rb
fedex-3.3.1 lib/fedex/tracking_information.rb
fedex-3.3.0 lib/fedex/tracking_information.rb
fedex-3.1.0 lib/fedex/tracking_information.rb