Converts HpsShippingInfo into expected format for Cardinal

@param HpsShippingInfo $shipping shipping information

@return array<string, string>
5614
protected function hydrateShippingInfo(HpsShippingInfo $shipping)
    {
        return array(
            'ShippingAddress1'    => $shipping->address->address,
            'ShippingCity'        => $shipping->address->city,
            'ShippingCountryCode' => $shipping->countryCode,
            'ShippingFirstName'   => $shipping->firstName,
            'ShippingLastName'    => $shipping->lastName,
            'ShippingMiddleName'  => $shipping->middleName,
            'ShippingPhone'       => $shipping->phoneNumber,
            'ShippingPostalCode'  => $shipping->address->zip,
            'ShippingState'       => $shipping->address->state,
        );
    }
139090
protected function getShipppingData($options)
    {
        parent::addEntry(
            $options['id'],
            $options['number'],
            'fa-truck',
            new DateTime($options['date']),
            parent::getRoute($options['id'], 'shipping', 'details'),
            null,
            'salesshipping.shipping'
        );
    }
1301794
private function getShippingAddress($address, $shipping = null)
    {
        if (!is_null($address) or !empty($adress))
            return $address;
        if ($shipping)
            return \UOL\PagSeguro\Helper\Data::addressConfig($shipping['street']);
        return null;
    }
50988
def build_ship_confirm(origin, destination, packages, options={})

      #Return Service types:
      #‘2’ = UPS Print and Mail (PNM)
      #‘3’ = UPS Return Service 1- Attempt (RS1)
      #‘5’ = UPS Return Service 3-Attempt (RS3)
      #‘8’ = UPS Electronic Return Label (ERL)
      #‘9’ = UPS Print Return Label (PRL)


      packages = Array(packages)
      builder = Nokogiri::XML::Builder.new do |xml|
        xml.ShipmentConfirmRequest {
          xml.Request {
            xml.RequestAction 'ShipConfirm'
            xml.RequestOption options[:nonvalidate] ? 'nonvalidate' : 'validate'
          }
          xml.Shipment {
            build_location_node(['Shipper'], (options[:shipper] || origin), options, xml)
            build_location_node(['ShipTo'], destination, options, xml)
            if options[:shipper] && options[:shipper] != origin
              build_location_node(['ShipFrom'], origin, options, xml)
            end
            xml.PaymentInformation {
              xml.Prepaid {
                xml.BillShipper {
                  xml.AccountNumber options[:origin_account]
                }
              }
            }
            if options[:return_service_code].present?
              xml.ReturnService {
                xml.Code options[:return_service_code]
                # if options[:return_service_description].present?
                #   xml.Description options[:return_service_description]
                # end
              }
            end
            xml.Service {
              xml.Code options[:service]
            }
            xml.ShipmentServiceOptions {
              xml.SaturdayDelivery if options[:saturday] == true
              if options[:delivery_confirmation_type].present?
                xml.DeliveryConfirmation {
                  xml.DCISType options[:delivery_confirmation_type]
                }
              end
            }
            packages.each do |package|
              imperial = ['US', 'LR', 'MM'].include?(origin.country_code(:alpha2))
              xml.Package {
                xml.PackagingType {
                  xml.Code package.options[:package_type]
                }
                xml.Dimensions {
                  xml.UnitOfMeasurement {
                    xml.Code imperial ? 'IN' : 'CM'
                  }
                  [:length, :width, :height].each do |axis|
                    value = ((imperial ? package.inches(axis) : package.cm(axis)).to_f*1000).round/1000.0 # 3 decimals
                    xml.send axis.to_s.gsub(/^[a-z]|\s+[-z]/) { |a| a.upcase }, [value, 0.1].max
                  end
                }
                xml.PackageWeight {
                  xml.UnitOfMeasurement {
                    xml.Code imperial ? 'LBS' : 'KGS'
                  }
                  value = ((imperial ? package.lbs : package.kgs).to_f*1000).round/1000.0 # decimals
                  xml.Weight [value, 0.1].max
                }
                xml.Description package.options[:package_description] if package.options[:package_description].present?
                xml.PackageServiceOptions {
                  if package.options[:delivery_confirmation_type].present?
                    xml.DeliveryConfirmation {
                      xml.DCISType package.options[:delivery_confirmation_type]
                    }
                  end
                }
                if package.options[:references].present?
                  package.options[:references].each do |reference|
                    xml.ReferenceNumber {
                      xml.Code reference[:code]
                      xml.Value reference[:value]
                      if reference[:barcode]
                        xml.BarCodeIndicator
                      end
                    }
                  end
                end
              }
            end
            xml.LabelSpecification {
              xml.LabelPrintMethod {
                xml.Code 'GIF'
              }
              xml.LabelImageFormat {
                xml.Code 'PNG'
              }
            }
          }
        }
      end
      builder.to_xml
    end
393642
protected function getPackageInformation($package)
    {
        $location = ($package['location'] === 'local') ? 'Local' : 'Vendor';

        $type = Str::title($package['type']);

        if ($this->packages->isEnabled($package['slug'])) {
            $status = 'Enabled';
        } else {
            $status = 'Disabled';
        }

        return array(
            'name'     => $package['name'],
            'slug'     => $package['slug'],
            'order'    => $package['order'],
            'location' => $location,
            'type'     => $type,
            'status'   => $status,
        );
    }
1268098
protected function splitShipToStreetPayPalUser($shipToStreet)
    {
        $address = oxNew(\OxidEsales\Eshop\Application\Model\Address::class);

        return $address->splitShipToStreetPayPalAddress($shipToStreet);
    }
1198778
protected function storeShippingMethodInfo($shippingMethod, $displayString)
    {
        $sdkId = $this->lookupShipMethod($shippingMethod);
        if (!$sdkId) {
            $this->logger->warning(
                'Encountered active shipping method with no ROM mapping.',
                $this->logContext->getMetaData(__CLASS__, ['shipping_method' => $shippingMethod, 'display_string' => $displayString])
            );
            return;
        }
        $this->methods[$shippingMethod] = [
            'sdk_id' => $sdkId,
            'display_text' => $displayString,
        ];
    }
1178361
public static function convertToShippoObject($resp, $apiKey)
    {
        // TODO: Have API Return Object: Type in order to cast properly
        $types = array(
            'QUOTE' => 'Shippo_Address'
        );
        if (self::isList($resp)) {
            $mapped = array();
            foreach ($resp as $i)
                array_push($mapped, self::convertToShippoObject($i, $apiKey));
            return $mapped;
        } else if (is_array($resp)) {
            if (isset($resp['object_purpose']) && is_string($resp['object_purpose']) && isset($types[$resp['object_purpose']])) {
                $class = $types[$resp['object_purpose']];
            } else {
                $class = 'Shippo_Object';
            }
            return Shippo_Object::scopedConstructFrom($class, $resp, $apiKey);
        } else {
            return $resp;
        }
    }
736496
private function _calculateOrderTotalBasedOnBuyerDestinationAddress()
    {
        $response = $this->callStepAndCheckForException('getOrderReferenceDetails');
        
        $this->printResponseToWebpage(
            "printGetOrderReferenceDetailsResponse", array($response)
        );

        $orderTotalPreTaxAndShipping
            = $this->_getPreTaxAndShippingOrderAmountFromQueryParams();
        $shippingType = $this->_getShippingTypeFromQueryParams();
    
        return $this->exampleClass->calculateOrderTotalBasedOnBuyerDetails(
            $response->getGetOrderReferenceDetailsResult()->getOrderReferenceDetails(),
            $orderTotalPreTaxAndShipping,
            $shippingType
        );
    }
909434
private function setShippingInformation()
    {
        $shipping = $this->_order->getShippingAddress();
        if ($shipping) {
            if (count($shipping->getStreet()) === 4) {
                $this->_paymentRequest->setShipping()->setAddress()->withParameters(
                    $shipping->getStreetLine(1),
                    $shipping->getStreetLine(2),
                    $shipping->getStreetLine(4),
                    \UOL\PagSeguro\Helper\Data::fixPostalCode($shipping->getPostcode()),
                    $shipping->getCity(),
                    $this->getRegionAbbreviation($shipping),
                    $this->getCountryName($shipping['country_id']),
                    $shipping->getStreetLine(3)
                );
            } else {
                $address = \UOL\PagSeguro\Helper\Data::addressConfig($shipping['street']);
                $this->_paymentRequest->setShipping()->setAddress()->withParameters(
                    $this->getShippingAddress($address[0], $shipping),
                    $this->getShippingAddress($address[1]),
                    $this->getShippingAddress($address[3]),
                    \UOL\PagSeguro\Helper\Data::fixPostalCode($shipping->getPostcode()),
                    $shipping->getCity(),
                    $this->getRegionAbbreviation($shipping),
                    $this->getCountryName($shipping['country_id']),
                    $this->getShippingAddress($address[2])
                );
            }

            $this->_paymentRequest->setShipping()->setType()
                ->withParameters(\PagSeguro\Enum\Shipping\Type::NOT_SPECIFIED); //Shipping Type
            $this->_paymentRequest->setShipping()->setCost()
                ->withParameters(number_format($this->getShippingAmount(), 2, '.', '')); //Shipping Coast
        }
    }
437105
private function generateShippingOptions(array $shipping_options) {
      $response = [];
      $option_index = 1;

      foreach ($shipping_options as $option => $prices) {
        array_push($response, ['id' => strval($option_index), 'title' => $option, 'prices' => []]);

        // Register prices for the specific shipping option
        foreach ($prices as $service => $price) {
          if ($price < 0) {
            throw new Exception('Invalid negative price passed to "answerShippingQuery"');
          }

          $formatted_price = intval($price * 100);

          // Selects the most recent shipping option pushed into the array.
          array_push($response[$option_index - 1]['prices'], [
            'label' => $service, 'amount' => $formatted_price
          ]);
        }

        $option_index++;
      }

      return json_encode($response);
    }
950904
private function convertItemStatus(Shipping $shipping, $shippingStatusId)
    {
        foreach ($shipping->getItems() as $shippingItem) {
            // get item
            $item = $shippingItem->getItem();

            // set item status based on current shipping status
            switch ($shippingStatusId) {
                // created
                case ShippingStatusEntity::STATUS_CREATED:
                    // TODO: REMOVE PREVIOUS STATE
                    $this->itemManager->addStatus($item, Item::STATUS_CREATED);
                    break;
                // delivery note
                case ShippingStatusEntity::STATUS_DELIVERY_NOTE:
                    if ($this->isPartiallyItem($shippingItem, true)) {
                        $itemStatus = Item::STATUS_SHIPPING_NOTE_PARTIALLY;
                    } else {
                        $itemStatus = Item::STATUS_SHIPPING_NOTE;

                    }
                    $this->itemManager->addStatus($item, $itemStatus);
                    break;
                // shipped
                case ShippingStatusEntity::STATUS_SHIPPED:
                    if ($this->isPartiallyItem($shippingItem, false)) {
                        $itemStatus = Item::STATUS_SHIPPED_PARTIALLY;
                    } else {
                        $itemStatus = Item::STATUS_SHIPPED;

                    }
                    $this->itemManager->addStatus($item, $itemStatus);
                    break;
                case ShippingStatusEntity::STATUS_CANCELED:
                    // TODO: check  if still fully shipped
                    $this->itemManager->removeStatus($item, Item::STATUS_SHIPPED);
                    // TODO: check if partially shipped
                    break;
            }
        }
    }
679802
public function setShippingInfo(array $shippingInfo)
    {
        $shippingInfo = [
          'shippingType'     => $this->sanitizeNumber($shippingInfo, 'shippingType'),
          'shippingCost'     => $this->sanitizeMoney($shippingInfo, 'shippingCost'),
        ];

        $this->validateShippingInfo($shippingInfo);
        $this->shippingInfo = $shippingInfo;

        return $this;
    }
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;
	}
77507
private function getLabelClass_v2($shipmentNumbers) {
		$data = new StdClass;

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

		if(is_array($shipmentNumbers)) {
			$this->checkRequestCount($shipmentNumbers, 'getLabel');

			foreach($shipmentNumbers as $key => &$number)
				$data->shipmentNumber[$key] = $number;
		} else
			$data->shipmentNumber = $shipmentNumbers;

		if($this->getLabelResponseType() !== null)
			$data->labelResponseType = $this->getLabelResponseType();

		return $data;
	}
1332709
public function getMethodSdkId($shippingMethod)
    {
        $this->fetchAvailableShippingMethods();
        if (!$shippingMethod) {
            $this->logger->error(
                'SDK shipping method id for empty shipping method requested.',
                $this->logContext->getMetaData(__CLASS__)
            );
            throw Mage::exception('Radial_Core', 'Unable to find a valid shipping method');
        }
        if (!isset($this->methods[$shippingMethod]['sdk_id'])) {
            $this->logger->error(
                'Unable to get the SDK identifier for shipping method {shipping_method}',
                $this->logContext->getMetaData(__CLASS__, ['shipping_method' => $shippingMethod])
            );
            throw Mage::exception('Radial_Core', 'Unable to find a valid shipping method');
        }
        return $this->methods[$shippingMethod]['sdk_id'];
    }
533589
protected static function deleteTableRateShippingByIdAsyncWithHttpInfo($table_rate_shipping_id) 
    {
        $returnType = '';  
        $request = self::deleteTableRateShippingByIdRequest($table_rate_shipping_id); 

        return self::getHttpClient()
            ->sendAsync($request, self::createHttpClientOption())
            ->then(
                function ($response) use ($returnType) {
                    return [null, $response->getStatusCode(), $response->getHeaders()];
                },
                function ($exception) {
                    $response = $exception->getResponse();
                    $statusCode = $response->getStatusCode();
                    throw new ApiException(
                        sprintf(
                            '[%d] Error connecting to the API (%s)',
                            $statusCode,
                            $exception->getRequest()->getUri()
                        ),
                        $statusCode,
                        $response->getHeaders(),
                        $response->getBody()
                    );
                }
            );
    }