Class: SolidusBacktracs::Api::BatchSyncer
- Inherits:
-
Object
- Object
- SolidusBacktracs::Api::BatchSyncer
- Defined in:
- lib/solidus_backtracs/api/batch_syncer.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#shipment_matcher ⇒ Object
readonly
Returns the value of attribute shipment_matcher.
Class Method Summary collapse
Instance Method Summary collapse
- #call(shipments) ⇒ Object
-
#initialize(client:, shipment_matcher:) ⇒ BatchSyncer
constructor
A new instance of BatchSyncer.
Constructor Details
#initialize(client:, shipment_matcher:) ⇒ BatchSyncer
Returns a new instance of BatchSyncer.
17 18 19 20 |
# File 'lib/solidus_backtracs/api/batch_syncer.rb', line 17 def initialize(client:, shipment_matcher:) @client = client @shipment_matcher = shipment_matcher end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
15 16 17 |
# File 'lib/solidus_backtracs/api/batch_syncer.rb', line 15 def client @client end |
#shipment_matcher ⇒ Object (readonly)
Returns the value of attribute shipment_matcher.
15 16 17 |
# File 'lib/solidus_backtracs/api/batch_syncer.rb', line 15 def shipment_matcher @shipment_matcher end |
Class Method Details
.from_config ⇒ Object
7 8 9 10 11 12 |
# File 'lib/solidus_backtracs/api/batch_syncer.rb', line 7 def from_config new( client: SolidusBacktracs::Api::Client.from_config, shipment_matcher: SolidusBacktracs.config.api_shipment_matcher, ) end |
Instance Method Details
#call(shipments) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solidus_backtracs/api/batch_syncer.rb', line 22 def call(shipments) begin response = client.bulk_create_orders(shipments) rescue RateLimitedError => e ::Spree::Event.fire( 'solidus_backtracs.api.rate_limited', shipments: shipments, error: e, ) raise e rescue RequestError => e ::Spree::Event.fire( 'solidus_backtracs.api.sync_errored', shipments: shipments, error: e, ) raise e end end |