Shipment detail.

@param  string|array  $shipment
@return array
328329
protected function shipment($shipment)
    {
        $data = [];

        if (is_array($shipment)) {
            if (isset($shipment['length']) && isset($shipment['width']) && isset($shipment['height'])) {
                $volumetric = (($shipment['length'] * $shipment['width'] * $shipment['height']) / 6000) * 1000;
                $actual = isset($shipment['weight']) ? $shipment['weight'] : 0;

                $data['weight'] = $volumetric > $actual ? $volumetric : $actual;
                $data['length'] = $shipment['length'];
                $data['width'] = $shipment['width'];
                $data['height'] = $shipment['height'];
            }
        } else {
            $data['weight'] = $shipment;
        }

        return $data;
    }
744824
public function getShipmentIdList(){
        if (!isset($this->planList)){
            return false;
        }
        $a = array();
        foreach($this->planList as $x){
            $a[] = $x['ShipmentId'];
        }
        return $a;
    }
250563
public function getShipmentOrderClass_v2() {
		$class = new StdClass;
		$class->sequenceNumber = $this->getSequenceNumber();

		// Shipment
		$class->Shipment = new StdClass;
		$class->Shipment->ShipmentDetails = $this->getShipmentDetails()->getShipmentDetailsClass_v2();

		// Shipper
		$class->Shipment->Shipper = $this->getSender()->getClass_v2();

		// Receiver
		$class->Shipment->Receiver = $this->getReceiver()->getClass_v2();

		// Return-Receiver
		if($this->getReturnReceiver() !== null)
			$class->Shipment->ReturnReceiver = $this->getReturnReceiver()->getClass_v2();

		// Export-Document
		if($this->getExportDocument() !== null) {
			try {
				$class->Shipment->ExportDocument = $this->getExportDocument()->getExportDocumentClass_v2();
			} catch(Exception $e) {
				trigger_error('[DHL-PHP-SDK]: Exception in method ' . __METHOD__ . ':' . $e->getMessage(), E_USER_WARNING);
			}
		}

		// Other Settings
		if($this->getPrintOnlyIfReceiverIsValid() !== null) {
			$class->PrintOnlyIfCodeable = new StdClass;
			$class->PrintOnlyIfCodeable->active = (int) $this->getPrintOnlyIfReceiverIsValid();
		}
		if($this->getLabelResponseType() !== null)
			$class->labelResponseType = $this->getLabelResponseType();

		return $class;
	}
703273
private function createShipmentClass_v2($shipmentNumber = null) {
		$shipmentOrders = $this->getShipmentOrders();

		$this->checkRequestCount($shipmentOrders, 'createShipmentClass');

		$data = new StdClass;
		$data->Version = $this->getVersionClass();

		if($shipmentNumber !== null)
			$data->shipmentNumber = (string) $shipmentNumber;

		foreach($shipmentOrders as $key => &$shipmentOrder) {
			/**
			 * @var ShipmentOrder $shipmentOrder
			 */
			// Set global response-type if none is defined in shipment
			if($shipmentOrder->getLabelResponseType() === null && $this->getLabelResponseType() !== null)
				$shipmentOrder->setLabelResponseType($this->getLabelResponseType());

			$data->ShipmentOrder[$key] = $shipmentOrder->getShipmentOrderClass_v2();
		}

		return $data;
	}
252915
public function getLabel($shipmentNumbers) {
		switch($this->getMayor()) {
			case 1:
				$data = $this->getLabelClass_v1($shipmentNumbers);
				break;
			case 2:
			default:
				$data = $this->getLabelClass_v2($shipmentNumbers);
		}

		try {
			$response = $this->sendGetLabelRequest($data);
		} catch(Exception $e) {
			$this->addError($e->getMessage());

			return false;
		}

		if(is_soap_fault($response)) {
			$this->addError($response->faultstring);

			return false;
		} else
			return new Response($this->getVersion(), $response);
	}
476442
public function updateShipmentOrder($shipmentNumber) {
		if(is_array($shipmentNumber) || $this->countShipmentOrders() > 1) {
			$this->addError(__FUNCTION__ . ': Updating Shipments is a Single-Operation only!');

			return false;
		}

		switch($this->getMayor()) {
			case 1:
				$data = null;
				break;
			case 2:
			default:
				if($this->countShipmentOrders() < 1)
					$data = $this->createShipmentClass_v2_legacy($shipmentNumber);
				else
					$data = $this->createShipmentClass_v2($shipmentNumber);
		}

		$response = null;

		// Create Shipment
		try {
			$response = $this->sendUpdateRequest($data);
		} catch(Exception $e) {
			$this->addError($e->getMessage());

			return false;
		}

		if(is_soap_fault($response)) {
			$this->addError($response->faultstring);

			return false;
		} else
			return new Response($this->getVersion(), $response);
	}
242730
private function setPaymentOptionsReceiverDetails($receivers)
    {
        return collect($receivers)->map(function ($receiver) {
            $item = [];

            $item['receiver'] = [
                'email' => $receiver['email'],
            ];

            $item['invoiceData']['item'] = collect($receiver['invoice_data'])->map(function ($invoice) {
                return $invoice;
            })->toArray();

            $item['description'] = $receiver['description'];

            return $item;
        })->toArray();
    }
991234
def taxes_for_shipment(shipment_key)
      shipment = shipment_sales_tax_rates.select { |s| s[:@shipment_key] == shipment_key }.first

      # convert attribute keys to symbols
      freight = attributes_to_symbols(shipment[:freight_sales_tax_rate])

      # wrap products in ProductSalesTaxRate
      products = wrap_products(shipment[:product_sales_tax_rates])

      ShipmentSalesTaxRate.new(shipment_key, FreightSalesTaxRate.new(freight), products)
    end
1066241
protected function getPackageMigrationPaths(string $package): array
    {
        return collect($this->option('path') ?: 'database/migrations')
                    ->map(function ($path) use ($package) {
                        return $this->packagePath.'/'.$package.'/'.$path;
                    })->all();
    }
1244233
protected function buildPackage(array $package) {
    if (isset($package['source'])) {
      $info = [
        'download' => [
          'type' => 'git',
          'url' => $package['source']['url'],
          'branch' => $package['version'],
          'revision' => $package['source']['reference'],
        ],
      ];
    }
    elseif (isset($package['dist'])) {
      $info = [
        'download' => [
          'type' => 'get',
          'url' => $package['dist']['url'],
        ],
      ];
    }

    if (isset($package['extra']['patches_applied'])) {
      $info['patch'] = array_values($package['extra']['patches_applied']);
    }
    return $info;
  }
368439
public function setShipmentOrders($shipmentOrders) {
		if(! is_array($shipmentOrders)) {
			trigger_error(
				'[DHL-PHP-SDK]: The type of $shipmentOrders is NOT an array, but is required to set as array! Called method ' .
				__METHOD__ . ' in class ' . __CLASS__,
				E_USER_ERROR
			);
			$this->addError(__METHOD__ . ': Non-Array value given');

			return;
		}

		$this->shipmentOrders = $shipmentOrders;
	}
1103821
public function getShippingOptions($quote, $addressData)
    {
        if ($quote->isVirtual()) {
            $billingAddress = $quote->getBillingAddress();
            $billingAddress->addData($addressData);

            $quote->collectTotals();

            $this->totalsCollector->collectAddressTotals($quote, $billingAddress);
            $taxAmount = $this->cartHelper->getRoundAmount($billingAddress->getTaxAmount());

            return [
                $this->shippingOptionInterfaceFactory
                    ->create()
                    ->setService(self::NO_SHIPPING_SERVICE)
                    ->setCost(0)
                    ->setReference(self::NO_SHIPPING_REFERENCE)
                    ->setTaxAmount($taxAmount)
            ];
        }

        $output = [];
        $appliedQuoteCouponCode = $quote->getCouponCode();

        $shippingAddress = $quote->getShippingAddress();
        $shippingAddress->addData($addressData);

        $shippingAddress->setCollectShippingRates(true);
        $shippingAddress->setShippingMethod(null);

        $quote->collectTotals();

        $this->totalsCollector->collectAddressTotals($quote, $shippingAddress);
        $shippingRates = $shippingAddress->getGroupedAllShippingRates();

        $this->resetShippingCalculationIfNeeded($shippingAddress);

        foreach ($shippingRates as $carrierRates) {
            foreach ($carrierRates as $rate) {
                $output[] = $this->converter->modelToDataObject($rate, $quote->getQuoteCurrencyCode());
            }
        }

        $shippingMethods = [];

        $errors = [];

        foreach ($output as $shippingMethod) {
            $service = $shippingMethod->getCarrierTitle() . ' - ' . $shippingMethod->getMethodTitle();
            $method  = $shippingMethod->getCarrierCode() . '_' . $shippingMethod->getMethodCode();

            $this->resetShippingCalculationIfNeeded($shippingAddress);

            $shippingAddress->setShippingMethod($method);
            // Since some types of coupon only work with specific shipping options,
            // for each shipping option, it need to recalculate the shipping discount amount
            if( ! empty($appliedQuoteCouponCode) ){
                $shippingAddress->setCollectShippingRates(true)
                                ->collectShippingRates()->save();
                $quote->setCouponCode('')->collectTotals()->save();                
                $quote->setCouponCode($appliedQuoteCouponCode)->collectTotals()->save();
            }
            
            // In order to get correct shipping discounts the following method must be called twice.
            // Being a bug in Magento, or a bug in the tested store version, shipping discounts
            // are not collected the first time the method is called.
            // There was one loop step delay in applying discount to shipping options when method was called once.
            $this->totalsCollector->collectAddressTotals($quote, $shippingAddress);
            $this->totalsCollector->collectAddressTotals($quote, $shippingAddress);

            $discountAmount = $shippingAddress->getShippingDiscountAmount();

            $cost        = $shippingAddress->getShippingAmount() - $discountAmount;
            $roundedCost = $this->cartHelper->getRoundAmount($cost);

            $diff = $cost * 100 - $roundedCost;

            $taxAmount = $this->cartHelper->getRoundAmount($shippingAddress->getTaxAmount() + $diff / 100);

            if ($discountAmount) {
                if ($cost == 0) {
                    $service .= ' [free&nbsp;shipping&nbsp;discount]';
                } else {
                    $discount = $this->priceHelper->currency($discountAmount, true, false);
                    $service .= " [$discount" . "&nbsp;discount]";
                }
                $service = html_entity_decode($service);
            }

            if (abs($diff) >= $this->threshold) {
                $this->taxAdjusted = true;
                $this->bugsnag->registerCallback(function ($report) use (
                    $method,
                    $diff,
                    $service,
                    $roundedCost,
                    $taxAmount
                ) {
                    $report->setMetaData([
                        'TOTALS_DIFF' => [
                            $method => [
                                'diff'       => $diff,
                                'service'    => $service,
                                'reference'  => $method,
                                'cost'       => $roundedCost,
                                'tax_amount' => $taxAmount,
                            ]
                        ]
                    ]);
                });
            }

            $error = $shippingMethod->getErrorMessage();

            if ($error) {
                $errors[] = [
                    'service'    => $service,
                    'reference'  => $method,
                    'cost'       => $roundedCost,
                    'tax_amount' => $taxAmount,
                    'error'      => $error,
                ];

                continue;
            }

            $shippingMethods[] = $this->shippingOptionInterfaceFactory
                ->create()
                ->setService($service)
                ->setCost($roundedCost)
                ->setReference($method)
                ->setTaxAmount($taxAmount);
        }

        $shippingAddress->setShippingMethod(null)->save();

        if ($errors) {
            $this->bugsnag->registerCallback(function ($report) use ($errors, $addressData) {
                $report->setMetaData([
                    'SHIPPING METHOD' => [
                      'address' => $addressData,
                      'errors'  => $errors
                    ]
                ]);
            });

            $this->bugsnag->notifyError('Shipping Method Error', $error);
        }

        if (!$shippingMethods) {
            $this->bugsnag->registerCallback(function ($report) use ($quote, $addressData) {
                $report->setMetaData([
                    'SHIPPING AND_TAX' => [
                        'address' => $addressData,
                        'immutable quote ID' => $quote->getId(),
                        'parent quote ID' => $quote->getBoltParentQuoteId(),
                        'order increment ID' => $quote->getReservedOrderId()
                    ]
                ]);
            });

            throw new BoltException(
                __('No Shipping Methods retrieved'),
                null,
                BoltErrorResponse::ERR_SERVICE
            );
        }

        return $shippingMethods;
    }
12854
def build_shipment_request(origin, destination, package, line_items = [], options = {})
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.public_send('non-contract-shipment', :xmlns => "http://www.canadapost.ca/ws/ncshipment") do
          xml.public_send('delivery-spec') do
            shipment_service_code_node(xml, options)
            shipment_sender_node(xml, origin, options)
            shipment_destination_node(xml, destination, options)
            shipment_options_node(xml, options)
            shipment_parcel_node(xml, package)
            shipment_notification_node(xml, options)
            shipment_preferences_node(xml, options)
            references_node(xml, options)             # optional > user defined custom notes
            shipment_customs_node(xml, destination, line_items, options)
            # COD Remittance defaults to sender
          end
        end
      end
      builder.to_xml
    end
454439
protected function prepareOrderShipment(OrderTransfer $orderTransfer, AbstractRequestContainer $container): AbstractRequestContainer
    {
        $arrayIt = $container->getIt() ?? [];
        $arrayId = $container->getId() ?? [];
        $arrayPr = $container->getPr() ?? [];
        $arrayNo = $container->getNo() ?? [];
        $arrayDe = $container->getDe() ?? [];
        $arrayVa = $container->getVa() ?? [];

        $key = count($arrayId) + 1;
        $expenses = $orderTransfer->getExpenses();

        $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_SHIPMENT;
        $arrayId[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_SHIPMENT;
        $arrayPr[$key] = $this->getDeliveryCosts($expenses);
        $arrayNo[$key] = 1;
        $arrayDe[$key] = 'Shipment';

        $container->setIt($arrayIt);
        $container->setId($arrayId);
        $container->setPr($arrayPr);
        $container->setNo($arrayNo);
        $container->setDe($arrayDe);
        $container->setVa($arrayVa);

        return $container;
    }
865343
private function _performAuthorizationForShipment($shipmentNumber)
    {
        $response = $this->callStepAndCheckForException(
            'performAuthorizationForShipment', 
            array($shipmentNumber, $this->currencyCode)
        );
        echo $this->printResponseToWebpage(
            "printAuthorizeResponse", 
            array($response)
        );
        
        return $response->getAuthorizeResult()
            ->getAuthorizationDetails()->getAmazonAuthorizationId();
    }
582080
public function isCaptureOnShipment()
    {
        $isPaymentOnShipmentStored = $this->GetUserPaymentDataItem(self::PARAMETER_IS_PAYMENT_ON_SHIPMENT);
        if (false !== $isPaymentOnShipmentStored) {
            return '1' === $isPaymentOnShipmentStored;
        }

        $config = $this->getAmazonPaymentGroupConfig($this->getActivePortalId());

        return $config->isCaptureOnShipment();
    }
1245742
public function getReportedShippingCollections()
    {
        try {
            return $this->encoder->decode($this->getData(self::FIELD_REPORTED_SHIPPING_COLLECTIONS)) ?: [];
        } catch (\InvalidArgumentException $e) {
            $this->_logger->error($e->getMessage());

            return [];
        }
    }