/**
  * @param CartInterface $quote
  * @return \Magento\Quote\Api\Data\ShippingAssignmentInterface
  */
 public function create(CartInterface $quote)
 {
     /** @var \Magento\Quote\Model\Quote $quote */
     $shippingAddress = $quote->getShippingAddress();
     /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $this->shippingAssignmentFactory->create();
     $shippingAssignment->setItems($quote->getItems());
     $shippingAssignment->setShipping($this->shippingProcessor->create($shippingAddress));
     return $shippingAssignment;
 }
 /**
  * @param \Magento\Quote\Model\Quote $quote
  * @param Address $address
  * @return Address\Total
  */
 public function collectAddressTotals(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address $address)
 {
     /** @var \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment */
     $shippingAssignment = $this->shippingAssignmentFactory->create();
     /** @var \Magento\Quote\Api\Data\ShippingInterface $shipping */
     $shipping = $this->shippingFactory->create();
     $shipping->setMethod($address->getShippingMethod());
     $shipping->setAddress($address);
     $shippingAssignment->setShipping($shipping);
     $shippingAssignment->setItems($address->getAllItems());
     /** @var \Magento\Quote\Model\Quote\Address\Total $total */
     $total = $this->totalFactory->create('Magento\\Quote\\Model\\Quote\\Address\\Total');
     $this->eventManager->dispatch('sales_quote_address_collect_totals_before', ['quote' => $quote, 'shipping_assignment' => $shippingAssignment, 'total' => $total]);
     foreach ($this->collectorList->getCollectors($quote->getStoreId()) as $collector) {
         /** @var CollectorInterface $collector */
         $collector->collect($quote, $shippingAssignment, $total);
     }
     $this->eventManager->dispatch('sales_quote_address_collect_totals_after', ['quote' => $quote, 'shipping_assignment' => $shippingAssignment, 'total' => $total]);
     $address->addData($total->getData());
     $address->setAppliedTaxes($total->getAppliedTaxes());
     return $total;
 }