Class: SpreeCmCommissioner::Integrations::VireakBuntham::Inventory::ExternalInventoryItems

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

Overview

Fetches the per-seat status for an order’s line items by querying VET’s POST /seat/unavailable for each (journey_id, depart_date) pair. journey_id is resolved from the trip’s IntegrationMapping external_payload. Available seats are inferred from the trip’s seat layout (any sellable block not in the unavailable list).

Instance Method Summary collapse

Instance Method Details

#call(integration:, order:) ⇒ Object



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

def call(integration:, order:)
  @integration = integration
  @order = order

  items = []
  order.line_items.each do |line_item|
    items.concat(fetch_items_for_line_item(line_item))
  end

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