Class: SpreeCmCommissioner::Integrations::VireakBuntham::Polling::SyncTripStop
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::Integrations::VireakBuntham::Polling::SyncTripStop
- Defined in:
- app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_trip_stop.rb
Overview
SyncTripStop — creates origin and destination TripStop records for a VET trip.
For each boarding/drop-off point it:
1. Finds the location VendorPlace (city-level) via the trip's origin/destination place_id.
2. Resolves (or creates) a stop-type Place with lat/lon from the boarding/dropOffList.
3. Creates a stop-type VendorPlace linked to the location VendorPlace.
4. Creates the TripStop referencing both stop_place and location_place.
Instance Method Summary collapse
- #call(trip_mapping:, schedule:, on_date: nil) ⇒ Object
-
#initialize(integration:, sync_result: nil) ⇒ SyncTripStop
constructor
A new instance of SyncTripStop.
Constructor Details
#initialize(integration:, sync_result: nil) ⇒ SyncTripStop
Returns a new instance of SyncTripStop.
12 13 14 15 16 17 18 19 20 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_trip_stop.rb', line 12 def initialize(integration:, sync_result: nil) @integration = integration @sync_result = sync_result || SpreeCmCommissioner::Integrations::Base::SyncResult.new @location_mappings = {} @place_resolver = SpreeCmCommissioner::PlaceResolver.new( integration: integration, sync_result: @sync_result ) end |
Instance Method Details
#call(trip_mapping:, schedule:, on_date: nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/services/spree_cm_commissioner/integrations/vireak_buntham/polling/sync_trip_stop.rb', line 25 def call(trip_mapping:, schedule:, on_date: nil) return nil if trip_mapping.blank? || schedule.blank? @trip_mapping = trip_mapping @schedule = schedule @on_date = on_date @departure_time = parse_time(@schedule.departure, @on_date) preload_location_mappings! sync_origin_stop! sync_destination_stop! end |