You are here

public function UPSShipment::getShipment in Commerce UPS 8.3

Creates and returns a UPS API shipment object.

Parameters

\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The commerce shipment.

\Drupal\commerce_shipping\Plugin\Commerce\ShippingMethod\ShippingMethodInterface $shipping_method: The shipping method.

Return value

\Ups\Entity\Shipment A Ups API shipment object.

Throws

\Drupal\Core\TypedData\Exception\MissingDataException

Overrides UPSShipmentInterface::getShipment

File

src/UPSShipment.php, line 51

Class

UPSShipment
Class to create and return a UPS API shipment object.

Namespace

Drupal\commerce_ups

Code

public function getShipment(ShipmentInterface $shipment, ShippingMethodInterface $shipping_method) {
  $this->shipment = $shipment;
  $this->shippingMethod = $shipping_method;
  $api_shipment = new APIShipment();
  $this
    ->setShipTo($api_shipment);
  $this
    ->setShipFrom($api_shipment);
  $this
    ->setPackage($api_shipment);
  return $api_shipment;
}