Module: Spree::SpreeChannable::ShipmentDecorator

Defined in:
app/models/spree/shipment_decorator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



5
6
7
# File 'app/models/spree/shipment_decorator.rb', line 5

def self.prepended(base)
  base.state_machine.after_transition to: :shipped, do: :send_shipment_update
end

Instance Method Details

#channable_shipmentObject



16
17
18
19
20
21
22
# File 'app/models/spree/shipment_decorator.rb', line 16

def channable_shipment
  {
      tracking_code: tracking,
      tracking_url: tracking_url,
      transporter: shipping_method.channable_transporter_code
  }.to_json
end

#send_shipment_updateObject



9
10
11
12
13
14
# File 'app/models/spree/shipment_decorator.rb', line 9

def send_shipment_update
  return unless order.is_channable_order?

  client = ::Channable::Client.new
  client.shipment_update(order.channable_order_id, channable_shipment)
end