Class: SpreeCmCommissioner::Integrations::Larryta::Inventory::ReleaseSeats

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/integrations/larryta/inventory/release_seats.rb

Instance Method Summary collapse

Instance Method Details

#call(integration:, order:, line_items:) ⇒ Object

Handles releasing seats when a user cancels or a hold expires. Process:

  1. Scope active mappings to avoid redundant DB calls.

  2. Communicate with Larryta API.

  3. Transition internal mapping states to :archived.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/spree_cm_commissioner/integrations/larryta/inventory/release_seats.rb', line 12

def call(integration:, order:, line_items:)
  ApplicationRecord.transaction do
    line_items.each do |line_item|
      release_line_item!(integration, order, line_item)
    end
  end

  success(order: order, line_items: line_items)
rescue SpreeCmCommissioner::Integrations::SyncError,
       SpreeCmCommissioner::Integrations::ExternalClientError => e
  failure(nil, e.message)
end