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

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

        if (null !== $this->requestOption) {
            $request->appendChild($xml->createElement('RequestOption', $this->requestOption));
        }

        if (null !== $this->trackingNumber) {
            $trackRequest->appendChild($xml->createElement('TrackingNumber', $this->trackingNumber));
        }

        if ($this->isMailInnovations()) {
            $trackRequest->appendChild($xml->createElement('IncludeMailInnovationIndicator'));
        }

        if (null !== $this->referenceNumber) {
            $trackRequest->appendChild($xml->createElement('ReferenceNumber'))->appendChild($xml->createElement('Value', $this->referenceNumber));
        }

        if (null !== $this->shipperNumber) {
            $trackRequest->appendChild($xml->createElement('ShipperNumber', $this->shipperNumber));
        }

        if (null !== $this->beginDate || null !== $this->endDate) {
            $DateRange = $xml->createElement('PickupDateRange');

            if (null !== $this->beginDate) {
                $beginDate = $this->beginDate->format('Ymd');
                $DateRange->appendChild($xml->createElement('BeginDate', $beginDate));
            }

            if (null !== $this->endDate) {
                $endDate = $this->endDate->format('Ymd');
                $DateRange->appendChild($xml->createElement('EndDate', $endDate));
            }

            $trackRequest->appendChild($DateRange);
        }

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

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

        if (null !== $this->requestOption) {
            $request->appendChild($xml->createElement('RequestOption', $this->requestOption));
        }

        if (null !== $this->trackingNumber) {
            $trackRequest->appendChild($xml->createElement('TrackingNumber', $this->trackingNumber));
        }

        if ($this->isMailInnovations()) {
            $trackRequest->appendChild($xml->createElement('IncludeMailInnovationIndicator'));
        }

        if (null !== $this->referenceNumber) {
            $trackRequest->appendChild($xml->createElement('ReferenceNumber'))->appendChild($xml->createElement('Value', $this->referenceNumber));
        }

        if (null !== $this->shipperNumber) {
            $trackRequest->appendChild($xml->createElement('ShipperNumber', $this->shipperNumber));
        }

        if (null !== $this->beginDate || null !== $this->endDate) {
            $DateRange = $xml->createElement('PickupDateRange');

            if (null !== $this->beginDate) {
                $beginDate = $this->beginDate->format('Ymd');
                $DateRange->appendChild($xml->createElement('BeginDate', $beginDate));
            }

            if (null !== $this->endDate) {
                $endDate = $this->endDate->format('Ymd');
                $DateRange->appendChild($xml->createElement('EndDate', $endDate));
            }

            $trackRequest->appendChild($DateRange);
        }

        return $xml->saveXML();
    }
private function createRequest ( ) { $ xml = new DOMDocument ( ) ; $ xml -> formatOutput = true ; $ trackRequest = $ xml -> appendChild ( $ xml -> createElement ( 'TrackRequest' ) ) ; $ 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' , 'Track' ) ) ; if ( null !== $ this -> requestOption ) { $ request -> appendChild ( $ xml -> createElement ( 'RequestOption' , $ this -> requestOption ) ) ; } if ( null !== $ this -> trackingNumber ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'TrackingNumber' , $ this -> trackingNumber ) ) ; } if ( $ this -> isMailInnovations ( ) ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'IncludeMailInnovationIndicator' ) ) ; } if ( null !== $ this -> referenceNumber ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'ReferenceNumber' ) ) -> appendChild ( $ xml -> createElement ( 'Value' , $ this -> referenceNumber ) ) ; } if ( null !== $ this -> shipperNumber ) { $ trackRequest -> appendChild ( $ xml -> createElement ( 'ShipperNumber' , $ this -> shipperNumber ) ) ; } if ( null !== $ this -> beginDate || null !== $ this -> endDate ) { $ DateRange = $ xml -> createElement ( 'PickupDateRange' ) ; if ( null !== $ this -> beginDate ) { $ beginDate = $ this -> beginDate -> format ( 'Ymd' ) ; $ DateRange -> appendChild ( $ xml -> createElement ( 'BeginDate' , $ beginDate ) ) ; } if ( null !== $ this -> endDate ) { $ endDate = $ this -> endDate -> format ( 'Ymd' ) ; $ DateRange -> appendChild ( $ xml -> createElement ( 'EndDate' , $ endDate ) ) ; } $ trackRequest -> appendChild ( $ DateRange ) ; } return $ xml -> saveXML ( ) ; }
Create the Tracking request.

@return string
Create the Tracking request .