Class: SolidusBacktracs::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/solidus_backtracs/api/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_runner:, error_handler:, shipment_serializer:) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
# File 'lib/solidus_backtracs/api/client.rb', line 18

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

Instance Attribute Details

#error_handlerObject (readonly)

Returns the value of attribute error_handler.



16
17
18
# File 'lib/solidus_backtracs/api/client.rb', line 16

def error_handler
  @error_handler
end

#request_runnerObject (readonly)

Returns the value of attribute request_runner.



16
17
18
# File 'lib/solidus_backtracs/api/client.rb', line 16

def request_runner
  @request_runner
end

#shipment_serializerObject (readonly)

Returns the value of attribute shipment_serializer.



16
17
18
# File 'lib/solidus_backtracs/api/client.rb', line 16

def shipment_serializer
  @shipment_serializer
end

Class Method Details

.from_configObject



7
8
9
10
11
12
13
# File 'lib/solidus_backtracs/api/client.rb', line 7

def from_config
  new(
    request_runner: RequestRunner.new,
    error_handler: SolidusBacktracs.config.error_handler,
    shipment_serializer: SolidusBacktracs.config.api_shipment_serializer,
  )
end

Instance Method Details

#bulk_create_orders(shipments) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/solidus_backtracs/api/client.rb', line 24

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