Class: SpreeCmCommissioner::Integrations::PollingJob

Inherits:
BaseJob show all
Defined in:
app/jobs/spree_cm_commissioner/integrations/polling_job.rb

Overview

Job that performs the actual polling (syncing) for a specific integration

This job is enqueued by PollingSchedulerJob and handles:

  • Full syncs: Complete refresh of all data

  • Incremental syncs: Fetch only recent changes

  • Webhook syncs: Real-time event processing (triggered externally)

Each integration type (StadiumXV1, LarrytaV1, etc.) must implement a sync_manager that responds to sync_full!, sync_incremental!, and sync_webhook!

Instance Method Summary collapse

Methods included from ApplicationJobDecorator

handle_deserialization_error, prepended

Instance Method Details

#perform(options) ⇒ Object

Perform the integration pull

Parameters:

  • integration_id (Integer)

    The integration ID

  • sync_type (String)

    The sync type: ‘full’, ‘incremental’, or ‘webhook_triggered’

  • event_type (String)

    Optional event type for webhook syncs

  • event_data (Hash)

    Optional event data for webhook syncs



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/jobs/spree_cm_commissioner/integrations/polling_job.rb', line 18

def perform(options)
  integration_id = options[:integration_id]
  sync_type = options[:sync_type]
  event_type = options[:event_type]
  event_data = options[:event_data]
  integration = SpreeCmCommissioner::Integration.find(integration_id)

  # integration is no longer active, skip processing.
  return unless integration.active?

  SpreeCmCommissioner::Integrations::Polling.new.call(
    integration: integration,
    sync_type: sync_type,
    event_type: event_type,
    event_data: event_data
  )
rescue StandardError => e
  handle_sync_error(e, options)
  raise
end