Beispiel #1
0
 /**
  * Create the TimeInTransit request.
  *
  * @param LocatorRequest $locatorRequest The request details. Refer to the UPS documentation for available structure
  * @param $requestOption
  *
  * @return string
  */
 private function createRequest(LocatorRequest $locatorRequest, $requestOption)
 {
     $xml = new DOMDocument();
     $xml->formatOutput = true;
     $trackRequest = $xml->appendChild($xml->createElement('LocatorRequest'));
     $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', 'Locator'));
     $request->appendChild($xml->createElement('RequestOption', $requestOption));
     // Origin Address
     $trackRequest->appendChild($locatorRequest->getOriginAddress()->toNode($xml));
     // Translate
     $trackRequest->appendChild($locatorRequest->getTranslate()->toNode($xml));
     // Unit of measurement
     if ($locatorRequest->getUnitOfMeasurement()) {
         $trackRequest->appendChild($locatorRequest->getUnitOfMeasurement()->toNode($xml));
     }
     // LocationSearchCriteria
     if ($locatorRequest->getLocationSearchCriteria()) {
         $trackRequest->appendChild($locatorRequest->getLocationSearchCriteria()->toNode($xml));
     }
     return $xml->saveXML();
 }