Class: Spree::Deliveries::UpdateTracking
- Defined in:
- app/workflows/spree/deliveries/update_tracking.rb
Overview
Records what the carrier says about one consignment in flight.
This is the carrier axis: it never moves the owner backwards and never
contradicts the merchant. A parcel that bounces or is damaged shows up
here as return_to_sender or failure while the fulfillment still
says fulfilled — the merchant did hand it over. The one status that
crosses over is delivered: when every delivery of a fulfillment has
arrived, the fulfillment is marked delivered through
Spree::Fulfillments::MarkDelivered. A Return owner never transitions —
goods arriving is not goods inspected, and Spree::Returns::Receive stays
a staff act; anything that wants to react hangs on
after_update_tracking.
Providers call this from their webhook handlers, so it accepts the already-normalized vocabulary rather than any carrier's raw payload: translating a provider's status names is the provider gem's job.
Instance Method Summary collapse
-
#perform(delivery:, tracking_status: nil, estimated_delivery_at: nil, delivered_at: nil, details: nil, notify_customer: true) ⇒ Spree::ServiceModule::Result
The updated delivery on success.
Methods inherited from Workflow
#call, define_argument_readers, #errors, #halt!, hooks, inherited, model_name, #read_attribute_for_validation, #reject!, workflow_key
Methods included from ServiceModule::Base
Methods included from Workflow::ControlFlow
Instance Method Details
#perform(delivery:, tracking_status: nil, estimated_delivery_at: nil, delivered_at: nil, details: nil, notify_customer: true) ⇒ Spree::ServiceModule::Result
Returns the updated delivery on success.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/workflows/spree/deliveries/update_tracking.rb', line 32 def perform(delivery:, tracking_status: nil, estimated_delivery_at: nil, delivered_at: nil, details: nil, notify_customer: true) super run_hooks :validate step :ensure_known_status step :apply_carrier_report step :roll_up_owner_delivery run_hooks :after_update_tracking success(delivery.reload) end |