private function createRequest(RateRequest $rateRequest)
    {
        $shipment = $rateRequest->getShipment();

        $document = $xml = new DOMDocument();
        $xml->formatOutput = true;

        /** @var DOMElement $trackRequest */
        $trackRequest = $xml->appendChild($xml->createElement('RatingServiceSelectionRequest'));
        $trackRequest->setAttribute('xml:lang', 'en-US');

        $request = $trackRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'Rate'));
        $request->appendChild($xml->createElement('RequestOption', $this->requestOption));

        $trackRequest->appendChild($rateRequest->getPickupType()->toNode($document));

        $customerClassification = $rateRequest->getCustomerClassification();
        if (isset($customerClassification)) {
            $trackRequest->appendChild($customerClassification->toNode($document));
        }

        $shipmentNode = $trackRequest->appendChild($xml->createElement('Shipment'));

        // Support specifying an individual service
        $service = $shipment->getService();
        if (isset($service)) {
            $shipmentNode->appendChild($service->toNode($document));
        }

        $shipper = $shipment->getShipper();
        if (isset($shipper)) {
            $shipmentNode->appendChild($shipper->toNode($document));
        }

        $shipFrom = $shipment->getShipFrom();
        if (isset($shipFrom)) {
            $shipmentNode->appendChild($shipFrom->toNode($document));
        }

        $shipTo = $shipment->getShipTo();
        if (isset($shipTo)) {
            $shipmentNode->appendChild($shipTo->toNode($document));
        }

        $alternateDeliveryAddress = $shipment->getAlternateDeliveryAddress();
        if (isset($alternateDeliveryAddress)) {
            $shipmentNode->appendChild($alternateDeliveryAddress->toNode($document));
        }

        $rateInformation = $shipment->getRateInformation();
        if ($rateInformation !== null) {
            $shipmentNode->appendChild($rateInformation->toNode($document));
        }

        $shipmentIndicationType = $shipment->getShipmentIndicationType();
        if (isset($shipmentIndicationType)) {
            $shipmentNode->appendChild($shipmentIndicationType->toNode($document));
        }

        foreach ($shipment->getPackages() as $package) {
            $shipmentNode->appendChild($package->toNode($document));
        }

        $shipmentServiceOptions = $shipment->getShipmentServiceOptions();
        if (isset($shipmentServiceOptions)) {
            $shipmentNode->appendChild($shipmentServiceOptions->toNode($xml));
        }

        $deliveryTimeInformation = $shipment->getDeliveryTimeInformation();
        if (isset($deliveryTimeInformation)) {
            $shipmentNode->appendChild($deliveryTimeInformation->toNode($xml));
        }
          
        $ShipmentTotalWeight = $shipment->getShipmentTotalWeight();
        if (isset($ShipmentTotalWeight)) {
            $shipmentNode->appendChild($ShipmentTotalWeight->toNode($xml));
        }
        
        $InvoiceLineTotal = $shipment->getInvoiceLineTotal();
        if (isset($InvoiceLineTotal)) {
            $shipmentNode->appendChild($InvoiceLineTotal->toNode($xml));
        }

        return $xml->saveXML();
    }
private function createRequest(RateRequest $rateRequest)
    {
        $shipment = $rateRequest->getShipment();

        $document = $xml = new DOMDocument();
        $xml->formatOutput = true;

        
        $trackRequest = $xml->appendChild($xml->createElement('RatingServiceSelectionRequest'));
        $trackRequest->setAttribute('xml:lang', 'en-US');

        $request = $trackRequest->appendChild($xml->createElement('Request'));

        $node = $xml->importNode($this->createTransactionNode(), true);
        $request->appendChild($node);

        $request->appendChild($xml->createElement('RequestAction', 'Rate'));
        $request->appendChild($xml->createElement('RequestOption', $this->requestOption));

        $trackRequest->appendChild($rateRequest->getPickupType()->toNode($document));

        $customerClassification = $rateRequest->getCustomerClassification();
        if (isset($customerClassification)) {
            $trackRequest->appendChild($customerClassification->toNode($document));
        }

        $shipmentNode = $trackRequest->appendChild($xml->createElement('Shipment'));

        
        $service = $shipment->getService();
        if (isset($service)) {
            $shipmentNode->appendChild($service->toNode($document));
        }

        $shipper = $shipment->getShipper();
        if (isset($shipper)) {
            $shipmentNode->appendChild($shipper->toNode($document));
        }

        $shipFrom = $shipment->getShipFrom();
        if (isset($shipFrom)) {
            $shipmentNode->appendChild($shipFrom->toNode($document));
        }

        $shipTo = $shipment->getShipTo();
        if (isset($shipTo)) {
            $shipmentNode->appendChild($shipTo->toNode($document));
        }

        $alternateDeliveryAddress = $shipment->getAlternateDeliveryAddress();
        if (isset($alternateDeliveryAddress)) {
            $shipmentNode->appendChild($alternateDeliveryAddress->toNode($document));
        }

        $rateInformation = $shipment->getRateInformation();
        if ($rateInformation !== null) {
            $shipmentNode->appendChild($rateInformation->toNode($document));
        }

        $shipmentIndicationType = $shipment->getShipmentIndicationType();
        if (isset($shipmentIndicationType)) {
            $shipmentNode->appendChild($shipmentIndicationType->toNode($document));
        }

        foreach ($shipment->getPackages() as $package) {
            $shipmentNode->appendChild($package->toNode($document));
        }

        $shipmentServiceOptions = $shipment->getShipmentServiceOptions();
        if (isset($shipmentServiceOptions)) {
            $shipmentNode->appendChild($shipmentServiceOptions->toNode($xml));
        }

        $deliveryTimeInformation = $shipment->getDeliveryTimeInformation();
        if (isset($deliveryTimeInformation)) {
            $shipmentNode->appendChild($deliveryTimeInformation->toNode($xml));
        }
          
        $ShipmentTotalWeight = $shipment->getShipmentTotalWeight();
        if (isset($ShipmentTotalWeight)) {
            $shipmentNode->appendChild($ShipmentTotalWeight->toNode($xml));
        }
        
        $InvoiceLineTotal = $shipment->getInvoiceLineTotal();
        if (isset($InvoiceLineTotal)) {
            $shipmentNode->appendChild($InvoiceLineTotal->toNode($xml));
        }

        return $xml->saveXML();
    }
private function createRequest ( RateRequest $ rateRequest ) { $ shipment = $ rateRequest -> getShipment ( ) ; $ document = $ xml = new DOMDocument ( ) ; $ xml -> formatOutput = true ; /** @var DOMElement $trackRequest */ $ trackRequest = $ xml -> appendChild ( $ xml -> createElement ( 'RatingServiceSelectionRequest' ) ) ; $ trackRequest -> setAttribute ( 'xml:lang' , 'en-US' ) ; $ request = $ trackRequest -> appendChild ( $ xml -> createElement ( 'Request' ) ) ; $ node = $ xml -> importNode ( $ this -> createTransactionNode ( ) , true ) ; $ request -> appendChild ( $ node ) ; $ request -> appendChild ( $ xml -> createElement ( 'RequestAction' , 'Rate' ) ) ; $ request -> appendChild ( $ xml -> createElement ( 'RequestOption' , $ this -> requestOption ) ) ; $ trackRequest -> appendChild ( $ rateRequest -> getPickupType ( ) -> toNode ( $ document ) ) ; $ customerClassification = $ rateRequest -> getCustomerClassification ( ) ; if ( isset ( $ customerClassification ) ) { $ trackRequest -> appendChild ( $ customerClassification -> toNode ( $ document ) ) ; } $ shipmentNode = $ trackRequest -> appendChild ( $ xml -> createElement ( 'Shipment' ) ) ; // Support specifying an individual service $ service = $ shipment -> getService ( ) ; if ( isset ( $ service ) ) { $ shipmentNode -> appendChild ( $ service -> toNode ( $ document ) ) ; } $ shipper = $ shipment -> getShipper ( ) ; if ( isset ( $ shipper ) ) { $ shipmentNode -> appendChild ( $ shipper -> toNode ( $ document ) ) ; } $ shipFrom = $ shipment -> getShipFrom ( ) ; if ( isset ( $ shipFrom ) ) { $ shipmentNode -> appendChild ( $ shipFrom -> toNode ( $ document ) ) ; } $ shipTo = $ shipment -> getShipTo ( ) ; if ( isset ( $ shipTo ) ) { $ shipmentNode -> appendChild ( $ shipTo -> toNode ( $ document ) ) ; } $ alternateDeliveryAddress = $ shipment -> getAlternateDeliveryAddress ( ) ; if ( isset ( $ alternateDeliveryAddress ) ) { $ shipmentNode -> appendChild ( $ alternateDeliveryAddress -> toNode ( $ document ) ) ; } $ rateInformation = $ shipment -> getRateInformation ( ) ; if ( $ rateInformation !== null ) { $ shipmentNode -> appendChild ( $ rateInformation -> toNode ( $ document ) ) ; } $ shipmentIndicationType = $ shipment -> getShipmentIndicationType ( ) ; if ( isset ( $ shipmentIndicationType ) ) { $ shipmentNode -> appendChild ( $ shipmentIndicationType -> toNode ( $ document ) ) ; } foreach ( $ shipment -> getPackages ( ) as $ package ) { $ shipmentNode -> appendChild ( $ package -> toNode ( $ document ) ) ; } $ shipmentServiceOptions = $ shipment -> getShipmentServiceOptions ( ) ; if ( isset ( $ shipmentServiceOptions ) ) { $ shipmentNode -> appendChild ( $ shipmentServiceOptions -> toNode ( $ xml ) ) ; } $ deliveryTimeInformation = $ shipment -> getDeliveryTimeInformation ( ) ; if ( isset ( $ deliveryTimeInformation ) ) { $ shipmentNode -> appendChild ( $ deliveryTimeInformation -> toNode ( $ xml ) ) ; } $ ShipmentTotalWeight = $ shipment -> getShipmentTotalWeight ( ) ; if ( isset ( $ ShipmentTotalWeight ) ) { $ shipmentNode -> appendChild ( $ ShipmentTotalWeight -> toNode ( $ xml ) ) ; } $ InvoiceLineTotal = $ shipment -> getInvoiceLineTotal ( ) ; if ( isset ( $ InvoiceLineTotal ) ) { $ shipmentNode -> appendChild ( $ InvoiceLineTotal -> toNode ( $ xml ) ) ; } return $ xml -> saveXML ( ) ; }
Create the Rate request.

@param RateRequest $rateRequest The request details. Refer to the UPS documentation for available structure

@return string
Create the Rate request .