Class: Spree::ShippingLabels::Record
- Defined in:
- app/workflows/spree/shipping_labels/record.rb
Overview
Records a label the merchant bought elsewhere — postage from a carrier site, a 3PL's PDF — so the parcel still has its file, its tracking number and what it cost, with no carrier integration involved.
The uploaded label mints its delivery like a purchased one; what it cannot do is be refunded through Spree, so deleting it is the way out.
Instance Attribute Summary collapse
-
#shipping_label ⇒ Object
readonly
The label that was recorded, readable by hook handlers.
Instance Method Summary collapse
-
#perform(owner:, file:, tracking_number:, carrier: nil, service: nil, cost: nil, currency: nil, file_format: nil, tracking_url: nil) ⇒ Spree::ServiceModule::Result
The shipping label 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 Spree::ServiceModule::Base
Methods included from Workflow::ControlFlow
Instance Attribute Details
#shipping_label ⇒ Object (readonly)
The label that was recorded, readable by hook handlers.
13 14 15 |
# File 'app/workflows/spree/shipping_labels/record.rb', line 13 def shipping_label @shipping_label end |
Instance Method Details
#perform(owner:, file:, tracking_number:, carrier: nil, service: nil, cost: nil, currency: nil, file_format: nil, tracking_url: nil) ⇒ Spree::ServiceModule::Result
Returns the shipping label on success.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/workflows/spree/shipping_labels/record.rb', line 25 def perform(owner:, file:, tracking_number:, carrier: nil, service: nil, cost: nil, currency: nil, file_format: nil, tracking_url: nil) super run_hooks :validate step :ensure_recordable ApplicationRecord.transaction do step :record_label step :record_delivery end run_hooks :after_record success(shipping_label.reload) end |