Class: Launchpad::IEO::OrderExecuteWorker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/workers/launchpad/ieo/order_execute_worker.rb

Overview

TODO: Document code.

Instance Method Summary collapse

Instance Method Details

#perform(ogid) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/workers/launchpad/ieo/order_execute_worker.rb', line 8

def perform(ogid)
  order = GlobalID::Locator.locate_signed(ogid, for: 'order_execute')

  Rails.logger.info { "Start #{order.id} order execution" }
  begin
    order.purchase!
  rescue ManagementAPIV2::Exception => e
    Rails.logger.error e.message
    # TODO: Later this logic will be moved to separate worker.
    # Which will create cancel transfer and cancel order if creation is
    # successful and change order state to something like undefined.
    order.restore_attributes
    order.cancel!
    return
  end
end