Class: SpreeCmCommissioner::Integrations::BookMeBusV1

Inherits:
SpreeCmCommissioner::Integration show all
Defined in:
app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb,
app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/seat.rb,
app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/seat_layout.rb,
app/services/spree_cm_commissioner/integrations/book_me_bus_v1/inventory/external_inventory_items.rb,
app/services/spree_cm_commissioner/integrations/book_me_bus_v1/inventory/external_inventory_item_status.rb

Defined Under Namespace

Modules: ExternalClient, Inventory, Polling, Resources, SyncStrategies Classes: SyncManager

Instance Method Summary collapse

Methods inherited from SpreeCmCommissioner::Integration

#hold_inventory!, #release_inventory!, #supports_auto_release_inventory?, #supports_external_inventory_holding?

Instance Method Details

#clientObject



53
54
55
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 53

def client
  @client ||= SpreeCmCommissioner::Integrations::BookMeBusV1::ExternalClient::Client.new(integration: self)
end

#external_inventory_item_status(order, options) ⇒ Object

override - Fetch detailed status for a specific external inventory item



36
37
38
39
40
41
42
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 36

def external_inventory_item_status(order, options)
  SpreeCmCommissioner::Integrations::BookMeBusV1::Inventory::ExternalInventoryItemStatus.new.call(
    integration: self,
    order: order,
    options: options
  )
end

#external_inventory_items(order) ⇒ Object

override - Fetch all external inventory items



28
29
30
31
32
33
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 28

def external_inventory_items(order)
  SpreeCmCommissioner::Integrations::BookMeBusV1::Inventory::ExternalInventoryItems.new.call(
    integration: self,
    order: order
  )
end

#restock_external_inventory!(_order, _line_items) ⇒ Object

override



25
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 25

def restock_external_inventory!(_order, _line_items); end

#sync_item_availability!(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 44

def sync_item_availability!(options = {})
  SpreeCmCommissioner::Integrations::BookMeBusV1::Polling::SyncItemAvailability.new(
    integration: self
  ).call(
    trip_id: options[:trip_id],
    on_date: options[:on_date]
  )
end

#sync_managerObject

override



9
10
11
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 9

def sync_manager
  SpreeCmCommissioner::Integrations::BookMeBusV1::SyncManager.new(integration: self)
end

#unstock_external_inventory!(order, line_items) ⇒ Object

override



14
15
16
17
18
19
20
21
22
# File 'app/models/spree_cm_commissioner/integrations/book_me_bus_v1.rb', line 14

def unstock_external_inventory!(order, line_items)
  result = SpreeCmCommissioner::Integrations::BookMeBusV1::Inventory::UnstockInventory.new.call(
    integration: self,
    order: order,
    line_items: line_items
  )

  raise SpreeCmCommissioner::Integrations::SyncError, result.error unless result.success?
end