Sha256: 999e68963d906f183f3bef7b67c093f3093032e67cae3710d886250c4e239b54
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
# frozen_string_literal: true module SolidusBactracs module Api class SyncShipmentsJob < ApplicationJob queue_as :default def perform(shipments) shipments = select_shipments(shipments) return if shipments.empty? sync_shipments(shipments) # Verify bactracs sync shipments.each { |shipment| VerifyBactracsSyncWorker.perform_async(shipment.id) } rescue RateLimitedError => e self.class.set(wait: e.retry_in).perform_later rescue StandardError => e SolidusBactracs.config.error_handler.call(e, {}) end private def select_shipments(shipments) shipments.select do |shipment| if ThresholdVerifier.call(shipment) true else ::Spree::Bus.publish(:'solidus_bactracs.api.sync_skipped', shipment:) false end end end def sync_shipments(shipments) BatchSyncer.from_config.call(shipments) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
solidus_bactracs-4.0.1 | app/jobs/solidus_bactracs/api/sync_shipments_job.rb |
solidus_bactracs-4.0.0 | app/jobs/solidus_bactracs/api/sync_shipments_job.rb |