Class: ReactiveShipping::TrackingResponse
- Defined in:
- lib/reactive_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
Instance Attribute Summary collapse
- #actual_delivery_date ⇒ Date, Time (also: #actual_delivery_time)
- #attempted_delivery_date ⇒ Date, Time (also: #attempted_delivery_time)
- #carrier ⇒ Symbol
- #carrier_name ⇒ String
- #delivery_signature ⇒ String
- #destination ⇒ ReactiveShipping::Location
- #origin ⇒ ReactiveShipping::Location
- #scheduled_delivery_date ⇒ Date, Time (also: #scheduled_delivery_time)
- #ship_time ⇒ Date, Time
- #shipment_events ⇒ Array<ReactiveShipping::ShipmentEvent>
- #shipper_address ⇒ ReactiveShipping::Location
- #status ⇒ Symbol
- #status_code ⇒ string
- #status_description ⇒ String
- #tracking_number ⇒ String
Attributes inherited from Response
#message, #params, #request, #test, #xml
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#has_exception? ⇒ Boolean
(also: #exception?)
Returns
true
if something out of the ordinary has happened during the delivery of this package. -
#initialize(success, message, params = {}, options = {}) ⇒ TrackingResponse
constructor
A new instance of TrackingResponse.
-
#is_delivered? ⇒ Boolean
(also: #delivered?)
Returns
true
if the shipment has arrived at the destination. -
#latest_event ⇒ ReactiveShipping::ShipmentEvent
(also: #exception_event)
The latest tracking event for this shipment, i.e.
Methods inherited from Response
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/reactive_shipping/tracking_response.rb', line 60 def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end |
Instance Attribute Details
#actual_delivery_date ⇒ Date, Time Also known as: actual_delivery_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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_date ⇒ Date, Time Also known as: attempted_delivery_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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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 ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_name ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_signature ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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 |
#destination ⇒ ReactiveShipping::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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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 |
#origin ⇒ ReactiveShipping::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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_date ⇒ Date, Time Also known as: scheduled_delivery_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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_time ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_events ⇒ Array<ReactiveShipping::ShipmentEvent>
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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_address ⇒ ReactiveShipping::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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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 ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_code ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_description ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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_number ⇒ 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/reactive_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 ReactiveShipping::Response#initialize) def initialize(success, , params = {}, = {}) @carrier = [:carrier].parameterize.to_sym @carrier_name = [:carrier] @status = [:status] @status_code = [:status_code] @status_description = [:status_description] @ship_time = [:ship_time] @scheduled_delivery_date = [:scheduled_delivery_date] @actual_delivery_date = [:actual_delivery_date] @attempted_delivery_date = [:attempted_delivery_date] @delivery_signature = [:delivery_signature] @tracking_number = [:tracking_number] @shipment_events = Array([:shipment_events]) @shipper_address = [:shipper_address] @origin = [:origin] @destination = [:destination] super end # The latest tracking event for this shipment, i.e. the current status. # @return [ReactiveShipping::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/reactive_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.
94 95 96 |
# File 'lib/reactive_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.
87 88 89 |
# File 'lib/reactive_shipping/tracking_response.rb', line 87 def is_delivered? @status == :delivered end |
#latest_event ⇒ ReactiveShipping::ShipmentEvent Also known as: exception_event
The latest tracking event for this shipment, i.e. the current status.
81 82 83 |
# File 'lib/reactive_shipping/tracking_response.rb', line 81 def latest_event @shipment_events.last end |