Class: SpreeCmCommissioner::Integrations::VireakBuntham::Polling::SyncRoutes

Inherits:
Object
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_routes.rb

Overview

SyncRoutes — builds Route records as origin/destination location pairs.

After SyncLocations populates VendorPlace mappings for every VET location, this service constructs all A→B and B→A pairs and upserts one SpreeCmCommissioner::Route per pair.

VET exposes only a flat location list, so routes are derived as all permutations of the synced :location-type VendorPlaces.

Instance Method Summary collapse

Constructor Details

#initialize(integration:, sync_result: nil) ⇒ SyncRoutes

Returns a new instance of SyncRoutes.



13
14
15
16
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_routes.rb', line 13

def initialize(integration:, sync_result: nil)
  @integration = integration
  @sync_result = sync_result || SpreeCmCommissioner::Integrations::Base::SyncResult.new
end

Instance Method Details

#callObject



18
19
20
21
22
23
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_routes.rb', line 18

def call
  raise SpreeCmCommissioner::Integrations::SyncError, 'Integration must have a vendor to sync routes' if @integration.vendor.blank?

  synced_mappings = sync_items!
  cleanup_stale_mappings!(synced_mappings)
end