Class: SpreeCmCommissioner::Integrations::VireakBuntham::Polling::SyncLocations
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Integrations::VireakBuntham::Polling::SyncLocations
- Defined in:
- app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_locations.rb
Overview
SyncLocations — syncs VET locations into BookMe+ Place / VendorPlace records.
Calls POST /destination/from (scoped to the integration’s route_type via the ‘type` param) and upserts one VendorPlace per returned location, resolved to a canonical Place via PlaceResolver.
Mirrors BookMeBusV1::Polling::SyncLocations exactly; only the client call and the PlaceResolver args differ (VET locations have no abbreviation or slug).
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(integration:, sync_result: nil) ⇒ SyncLocations
constructor
A new instance of SyncLocations.
Constructor Details
#initialize(integration:, sync_result: nil) ⇒ SyncLocations
Returns a new instance of SyncLocations.
13 14 15 16 17 18 19 20 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_locations.rb', line 13 def initialize(integration:, sync_result: nil) @integration = integration @sync_result = sync_result || SpreeCmCommissioner::Integrations::Base::SyncResult.new @place_resolver = SpreeCmCommissioner::PlaceResolver.new( integration: integration, sync_result: @sync_result ) end |
Instance Method Details
#call ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_locations.rb', line 22 def call raise SpreeCmCommissioner::Integrations::SyncError, 'Integration must have a vendor to sync locations' if @integration.vendor.blank? synced_location_mappings = sync_items! cleanup_stale_mappings!(synced_location_mappings) end |