Module: SolidusBactracs::Spree::ShipmentDecorator

Included in:
Spree::Shipment
Defined in:
app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



6
7
8
# File 'app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb', line 6

def self.prepended(base)
  base.singleton_class.prepend ClassMethods
end

Instance Method Details

#verify_bactracs_sync!Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/decorators/models/solidus_bactracs/spree/shipment_decorator.rb', line 10

def verify_bactracs_sync!
  if bactracs_sync_verified_at.nil?
    # API call to verify RMAs of shipments
    if BactracsService.new.rma_was_synced?(self)
      self.update_column(:bactracs_sync_verified_at, Time.now)
    else
      self.update_column(:bactracs_synced_at, nil)
    end
  end
rescue => e
  Rails.logger.error({ message: "#{e.message}, file: shipment_decorator.rb", shipment_number: number })
end