src/TimeInTransit.php
private function createRequest(TimeInTransitRequest $timeInTransitRequest)
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $trackRequest = $xml->appendChild($xml->createElement('TimeInTransitRequest'));
        $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', 'TimeInTransit'));

        $transitFromNode = $trackRequest->appendChild($xml->createElement('TransitFrom'));
        $address = $timeInTransitRequest->getTransitFrom();
        if (isset($address)) {
            $transitFromNode->appendChild($address->toNode($xml));
        }

        $transitToNode = $trackRequest->appendChild($xml->createElement('TransitTo'));
        $address = $timeInTransitRequest->getTransitTo();
        if (isset($address)) {
            $transitToNode->appendChild($address->toNode($xml));
        }

        $weight = $timeInTransitRequest->getShipmentWeight();
        if (isset($weight)) {
            $trackRequest->appendChild($weight->toNode($xml));
        }

        $packages = $timeInTransitRequest->getTotalPackagesInShipment();
        if (isset($packages)) {
            $trackRequest->appendChild($xml->createElement('TotalPackagesInShipment', $packages));
        }

        $invoiceLineTotal = $timeInTransitRequest->getInvoiceLineTotal();
        if (isset($invoiceLineTotal)) {
            $trackRequest->appendChild($invoiceLineTotal->toNode($xml));
        }

        $pickupDate = $timeInTransitRequest->getPickupDate();
        if ($pickupDate) {
            $trackRequest->appendChild($xml->createElement('PickupDate', $pickupDate->format('Ymd')));
        }

        $indicator = $timeInTransitRequest->getDocumentsOnlyIndicator();
        if ($indicator) {
            $trackRequest->appendChild($xml->createElement('DocumentsOnlyIndicator'));
        }

        return $xml->saveXML();
    }
private function createRequest(TimeInTransitRequest $timeInTransitRequest)
    {
        $xml = new DOMDocument();
        $xml->formatOutput = true;

        $trackRequest = $xml->appendChild($xml->createElement('TimeInTransitRequest'));
        $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', 'TimeInTransit'));

        $transitFromNode = $trackRequest->appendChild($xml->createElement('TransitFrom'));
        $address = $timeInTransitRequest->getTransitFrom();
        if (isset($address)) {
            $transitFromNode->appendChild($address->toNode($xml));
        }

        $transitToNode = $trackRequest->appendChild($xml->createElement('TransitTo'));
        $address = $timeInTransitRequest->getTransitTo();
        if (isset($address)) {
            $transitToNode->appendChild($address->toNode($xml));
        }

        $weight = $timeInTransitRequest->getShipmentWeight();
        if (isset($weight)) {
            $trackRequest->appendChild($weight->toNode($xml));
        }

        $packages = $timeInTransitRequest->getTotalPackagesInShipment();
        if (isset($packages)) {
            $trackRequest->appendChild($xml->createElement('TotalPackagesInShipment', $packages));
        }

        $invoiceLineTotal = $timeInTransitRequest->getInvoiceLineTotal();
        if (isset($invoiceLineTotal)) {
            $trackRequest->appendChild($invoiceLineTotal->toNode($xml));
        }

        $pickupDate = $timeInTransitRequest->getPickupDate();
        if ($pickupDate) {
            $trackRequest->appendChild($xml->createElement('PickupDate', $pickupDate->format('Ymd')));
        }

        $indicator = $timeInTransitRequest->getDocumentsOnlyIndicator();
        if ($indicator) {
            $trackRequest->appendChild($xml->createElement('DocumentsOnlyIndicator'));
        }

        return $xml->saveXML();
    }
private function createRequest ( TimeInTransitRequest $ timeInTransitRequest ) { $ xml = new DOMDocument ( ) ; $ xml -> formatOutput = true ; $ trackRequest = $ xml -> appendChild ( $ xml -> createElement ( 'TimeInTransitRequest' ) ) ; $ 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' , 'TimeInTransit' ) ) ; $ transitFromNode = $ trackRequest -> appendChild ( $ xml -> createElement ( 'TransitFrom' ) ) ; $ address = $ timeInTransitRequest -> getTransitFrom ( ) ; if ( isset ( $ address ) ) { $ transitFromNode -> appendChild ( $ address -> toNode ( $ xml ) ) ; } $ transitToNode = $ trackRequest -> appendChild ( $ xml -> createElement ( 'TransitTo' ) ) ; $ address = $ timeInTransitRequest -> getTransitTo ( ) ; if ( isset ( $ address ) ) { $ transitToNode -> appendChild ( $ address -> toNode ( $ xml ) ) ; } $ weight = $ timeInTransitRequest -> getShipmentWeight ( ) ; if ( isset ( $ weight ) ) { $ trackRequest -> appendChild ( $ weight -> toNode ( $ xml ) ) ; } $ packages = $ timeInTransitRequest -> getTotalPackagesInShipment ( ) ; if ( isset ( $ packages ) ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'TotalPackagesInShipment' , $ packages ) ) ; } $ invoiceLineTotal = $ timeInTransitRequest -> getInvoiceLineTotal ( ) ; if ( isset ( $ invoiceLineTotal ) ) { $ trackRequest -> appendChild ( $ invoiceLineTotal -> toNode ( $ xml ) ) ; } $ pickupDate = $ timeInTransitRequest -> getPickupDate ( ) ; if ( $ pickupDate ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'PickupDate' , $ pickupDate -> format ( 'Ymd' ) ) ) ; } $ indicator = $ timeInTransitRequest -> getDocumentsOnlyIndicator ( ) ; if ( $ indicator ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'DocumentsOnlyIndicator' ) ) ; } return $ xml -> saveXML ( ) ; }
Create the TimeInTransit request.

@param TimeInTransitRequest $timeInTransitRequest The request details. Refer to the UPS documentation for available structure

@return string
Create the TimeInTransit request .