Class: SolidusEasypost::ShipmentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/solidus_easypost/shipment_builder.rb

Class Method Summary collapse

Class Method Details

.from_package(package) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/solidus_easypost/shipment_builder.rb', line 6

def from_package(package)
  ::EasyPost::Shipment.create(
    to_address: AddressBuilder.from_address(package.order.ship_address),
    from_address: AddressBuilder.from_stock_location(package.stock_location),
    parcel: ParcelBuilder.from_package(package),
  )
end

.from_return_authorization(return_authorization) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/solidus_easypost/shipment_builder.rb', line 22

def from_return_authorization(return_authorization)
  ::EasyPost::Shipment.create(
    from_address: AddressBuilder.from_stock_location(return_authorization.stock_location),
    to_address: AddressBuilder.from_address(return_authorization.order.ship_address),
    parcel: ParcelBuilder.from_return_authorization(return_authorization),
    is_return: true
  )
end

.from_shipment(shipment) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/solidus_easypost/shipment_builder.rb', line 14

def from_shipment(shipment)
  ::EasyPost::Shipment.create(
    to_address: AddressBuilder.from_address(shipment.order.ship_address),
    from_address: AddressBuilder.from_stock_location(shipment.stock_location),
    parcel: ParcelBuilder.from_package(shipment.to_package),
  )
end