Class: SolidusBactracs::ShipmentNotice

Inherits:
Object
  • Object
show all
Defined in:
lib/solidus_bactracs/shipment_notice.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shipment_number:, shipment_tracking:) ⇒ ShipmentNotice

Returns a new instance of ShipmentNotice.



16
17
18
19
# File 'lib/solidus_bactracs/shipment_notice.rb', line 16

def initialize(shipment_number:, shipment_tracking:)
  @shipment_number = shipment_number
  @shipment_tracking = shipment_tracking
end

Instance Attribute Details

#shipment_numberObject (readonly)

Returns the value of attribute shipment_number.



5
6
7
# File 'lib/solidus_bactracs/shipment_notice.rb', line 5

def shipment_number
  @shipment_number
end

#shipment_trackingObject (readonly)

Returns the value of attribute shipment_tracking.



5
6
7
# File 'lib/solidus_bactracs/shipment_notice.rb', line 5

def shipment_tracking
  @shipment_tracking
end

Class Method Details

.from_payload(params) ⇒ Object



8
9
10
11
12
13
# File 'lib/solidus_bactracs/shipment_notice.rb', line 8

def from_payload(params)
  new(
    shipment_number: params[:order_number],
    shipment_tracking: params[:tracking_number],
  )
end

Instance Method Details

#applyObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/solidus_bactracs/shipment_notice.rb', line 21

def apply
  unless shipment
    raise ShipmentNotFoundError, shipment
  end

  process_payment
  ship_shipment

  shipment
end