Class: ActiveShipping::TrackingResponse

Inherits:
Response
  • Object
show all
Defined in:
lib/active_shipping/tracking_response.rb

Overview

Note:

Some carriers provide more information than others, so not all attributes will be set, depending on what carrier you are using.

Represents the response to a Carrier#find_tracking_info call.

Direct Known Subclasses

CPPWSTrackingResponse

Instance Attribute Summary collapse

Attributes inherited from Response

#message, #params, #request, #test, #xml

Instance Method Summary collapse

Methods inherited from Response

#success?, #test?

Constructor Details

#initialize(success, message, params = {}, options = {}) ⇒ TrackingResponse

Returns a new instance of TrackingResponse.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/active_shipping/tracking_response.rb', line 60

def initialize(success, message, params = {}, options = {})
  @carrier = options[:carrier].parameterize.to_sym
  @carrier_name = options[:carrier]
  @status = options[:status]
  @status_code = options[:status_code]
  @status_description = options[:status_description]
  @ship_time = options[:ship_time]
  @scheduled_delivery_date = options[:scheduled_delivery_date]
  @actual_delivery_date = options[:actual_delivery_date]
  @attempted_delivery_date = options[:attempted_delivery_date]
  @delivery_signature = options[:delivery_signature]
  @tracking_number = options[:tracking_number]
  @shipment_events = Array(options[:shipment_events])
  @shipper_address = options[:shipper_address]
  @origin = options[:origin]
  @destination = options[:destination]
  super
end

Instance Attribute Details

#actual_delivery_dateDate, Time Also known as: actual_delivery_time

Returns:

  • (Date, Time)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#attempted_delivery_dateDate, Time Also known as: attempted_delivery_time

Returns:

  • (Date, Time)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#carrierSymbol

Returns:

  • (Symbol)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#carrier_nameString

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#delivery_signatureString

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#destinationActiveShipping::Location



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#originActiveShipping::Location



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#scheduled_delivery_dateDate, Time Also known as: scheduled_delivery_time

Returns:

  • (Date, Time)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#ship_timeDate, Time

Returns:

  • (Date, Time)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#shipment_eventsArray<ActiveShipping::ShipmentEvent>

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#shipper_addressActiveShipping::Location



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#statusSymbol

Returns:

  • (Symbol)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#status_codestring

Returns:

  • (string)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#status_descriptionString

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

#tracking_numberString

Returns:

  • (String)


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/active_shipping/tracking_response.rb', line 52

class TrackingResponse < Response
  attr_reader :carrier,:carrier_name,
              :status,:status_code, :status_description,
              :ship_time, :scheduled_delivery_date, :actual_delivery_date, :attempted_delivery_date,
              :delivery_signature, :tracking_number, :shipment_events,
              :shipper_address, :origin, :destination

  # @params (see ActiveShipping::Response#initialize)
  def initialize(success, message, params = {}, options = {})
    @carrier = options[:carrier].parameterize.to_sym
    @carrier_name = options[:carrier]
    @status = options[:status]
    @status_code = options[:status_code]
    @status_description = options[:status_description]
    @ship_time = options[:ship_time]
    @scheduled_delivery_date = options[:scheduled_delivery_date]
    @actual_delivery_date = options[:actual_delivery_date]
    @attempted_delivery_date = options[:attempted_delivery_date]
    @delivery_signature = options[:delivery_signature]
    @tracking_number = options[:tracking_number]
    @shipment_events = Array(options[:shipment_events])
    @shipper_address = options[:shipper_address]
    @origin = options[:origin]
    @destination = options[:destination]
    super
  end

  # The latest tracking event for this shipment, i.e. the current status.
  # @return [ActiveShipping::ShipmentEvent]
  def latest_event
    @shipment_events.last
  end

  # Returns `true` if the shipment has arrived at the destination.
  # @return [Boolean]
  def is_delivered?
    @status == :delivered
  end

  # Returns `true` if something out of the ordinary has happened during
  # the delivery of this package.
  # @return [Boolean]
  def has_exception?
    @status == :exception
  end

  alias_method :exception_event, :latest_event
  alias_method :delivered?, :is_delivered?
  alias_method :exception?, :has_exception?
  alias_method :scheduled_delivery_time, :scheduled_delivery_date
  alias_method :actual_delivery_time, :actual_delivery_date
  alias_method :attempted_delivery_time, :attempted_delivery_date

  def ==(other)
    attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
      actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
      origin destination
    )

    attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
  end

  private
  # Ensure order doesn't matter when comparing shipment_events
  def compare_shipment_events(other)
    shipment_events.sort_by(&:time) == other.shipment_events.sort_by(&:time)
  end
end

Instance Method Details

#==(other) ⇒ Object



105
106
107
108
109
110
111
112
# File 'lib/active_shipping/tracking_response.rb', line 105

def ==(other)
  attributes = %i(carrier carrier_name status status_code status_description ship_time scheduled_delivery_date
    actual_delivery_date attempted_delivery_date delivery_signature tracking_number shipper_address
    origin destination
  )

  attributes.all? { |attr| self.public_send(attr) == other.public_send(attr) } && compare_shipment_events(other)
end

#has_exception?Boolean Also known as: exception?

Returns true if something out of the ordinary has happened during the delivery of this package.

Returns:

  • (Boolean)


94
95
96
# File 'lib/active_shipping/tracking_response.rb', line 94

def has_exception?
  @status == :exception
end

#is_delivered?Boolean Also known as: delivered?

Returns true if the shipment has arrived at the destination.

Returns:

  • (Boolean)


87
88
89
# File 'lib/active_shipping/tracking_response.rb', line 87

def is_delivered?
  @status == :delivered
end

#latest_eventActiveShipping::ShipmentEvent Also known as: exception_event

The latest tracking event for this shipment, i.e. the current status.



81
82
83
# File 'lib/active_shipping/tracking_response.rb', line 81

def latest_event
  @shipment_events.last
end