예제 #1
0
 /**
  * Adds location information including company name, attention name and address
  *
  * @param $location
  * @param DOMNode $locationNode
  * @deprecated Use NodeInterface on entities instead
  */
 public static function addLocationInformation($location, DOMNode $locationNode)
 {
     self::appendChild($location, "CompanyName", $locationNode);
     self::appendChild($location, "AttentionName", $locationNode);
     if (isset($location->Address)) {
         Utilities::addAddressNode($location->Address, $locationNode);
     }
 }
예제 #2
0
 /**
  * Create the TimeInTransit request
  *
  * @param TimeInTransitRequest $timeInTransitRequest The request details. Refer to the UPS documentation for available structure
  * @return string
  */
 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'));
     if (isset($timeInTransitRequest->TransitFrom)) {
         Utilities::addAddressArtifactNode($timeInTransitRequest->TransitFrom, $transitFromNode);
     }
     $transitToNode = $trackRequest->appendChild($xml->createElement('TransitTo'));
     if (isset($timeInTransitRequest->TransitTo)) {
         Utilities::addAddressArtifactNode($timeInTransitRequest->TransitTo, $transitToNode);
     }
     $shipmentWeightNode = $trackRequest->appendChild($xml->createElement('ShipmentWeight'));
     if (isset($timeInTransitRequest->ShipmentWeight)) {
         $shipmentWeightNode->appendChild($xml->createElement("Weight", $timeInTransitRequest->ShipmentWeight->Weight));
         $uom = $shipmentWeightNode->appendChild($xml->createElement("UnitOfMeasurement"));
         $uom->appendChild($xml->createElement("Code", $timeInTransitRequest->ShipmentWeight->UnitOfMeasurement->Code));
         $uom->appendChild($xml->createElement("Description", $timeInTransitRequest->ShipmentWeight->UnitOfMeasurement->Description));
     }
     if (isset($timeInTransitRequest->TotalPackagesInShipment)) {
         $trackRequest->appendChild($xml->createElement("TotalPackagesInShipment", $timeInTransitRequest->TotalPackagesInShipment));
     }
     $invoiceLineTotalNode = $trackRequest->appendChild($xml->createElement('InvoiceLineTotal'));
     if (isset($timeInTransitRequest->InvoiceLineTotal)) {
         $invoiceLineTotalNode->appendChild($xml->createElement("CurrencyCode", $timeInTransitRequest->InvoiceLineTotal->CurrencyCode));
         $invoiceLineTotalNode->appendChild($xml->createElement("MonetaryValue", $timeInTransitRequest->InvoiceLineTotal->MonetaryValue));
     }
     if (isset($timeInTransitRequest->PickupDate)) {
         $trackRequest->appendChild($xml->createElement("PickupDate", $timeInTransitRequest->PickupDate));
     }
     $trackRequest->appendChild($xml->createElement("DocumentsOnlyIndicator"));
     return $xml->saveXML();
 }