Sha256: 2fc59c693af1cac0f3e36b73b594f27ed674b7e1adbc72999be46239c79e1f7a

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

module SolidusBacktracs
  module Api
    class Client
      class << self
        def from_config
          new(
            request_runner: RequestRunner.new,
            error_handler: SolidusBacktracs.config.error_handler,
            shipment_serializer: SolidusBacktracs.config.api_shipment_serializer,
          )
        end
      end

      attr_reader :request_runner, :error_handler, :shipment_serializer

      def initialize(request_runner:, error_handler:, shipment_serializer:)
        @request_runner = request_runner
        @error_handler = error_handler
        @shipment_serializer = shipment_serializer
      end

      def bulk_create_orders(shipments)
        shipments.each do |shipment|
          SolidusBacktracs::Api::SyncShipmentJob.perform_now(
            shipment_id: shipment.id,
            error_handler: @error_handler,
            shipment_serializer: @shipment_serializer,
            request_runner: @request_runner
          )
        end.compact
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
solidus_bactracs-3.0.0 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.6 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.5 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.4 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.3 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.2 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.1 lib/solidus_backtracs/api/client.rb
solidus_backtracs-2.2.0 lib/solidus_backtracs/api/client.rb