Class: Workarea::Orderbot::Fulfillment::ImportFulfillments

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/workarea/orderbot/fulfillment/import_fulfillments.rb

Instance Method Summary collapse

Instance Method Details

#perform(attrs = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'app/workers/workarea/orderbot/fulfillment/import_fulfillments.rb', line 7

def perform(attrs = {})
  fulfillment_data = attrs.deep_symbolize_keys
  order_id = fulfillment_data[:reference_id]

  order = Workarea::Order.find(order_id)
  fulfillment = Workarea::Fulfillment.find(order_id)

  fulfillment_data[:packages].each do |package|
    ship_package(package, order, fulfillment)
  end
end