Ejemplo n.º 1
0
 /**
  * @internal
  *
  * @param \SimpleXMLElement $xml
  *
  * @return Shipment
  */
 public static function fromXml(\SimpleXMLElement $xml)
 {
     $shipment = new Shipment();
     $shipment->setIsResponse();
     if (isset($xml->PickupDate)) {
         $shipment->setPickupDate(new \DateTime((string) $xml->PickupDate));
     }
     if (isset($xml->ScheduledDeliveryDate) && isset($xml->ScheduledDeliveryTime)) {
         $shipment->setDeliveryTime(new \DateTime((string) trim($xml->ScheduledDeliveryDate . ' ' . $xml->ScheduledDeliveryTime)));
     }
     if (isset($xml->ShipmentType)) {
         $shipment->setShipmentType(ShipmentType::fromXml($xml->ShipmentType));
     }
     if (isset($xml->Shipper)) {
         $shipment->setShipper(Shipper::fromXml($xml->Shipper));
     }
     if (isset($xml->ShipTo->Address)) {
         $shipment->setDestination(InstructionalAddress::fromXml($xml->ShipTo->Address));
     }
     if (isset($xml->Package)) {
         foreach ($xml->Package as $package) {
             $shipment->addPackage(Package::fromXml($package));
         }
     }
     if (isset($xml->Service)) {
         $shipment->setService(Service::fromXml($xml->Service));
     }
     if (isset($xml->CurrentStatus)) {
         $shipment->setStatus(Status::fromXml($xml->CurrentStatus));
     }
     if (isset($xml->ReferenceNumber)) {
         $shipment->setReferenceNumber(ReferenceNumber::fromXml($xml->ReferenceNumber));
     }
     if (isset($xml->ShipmentWeight)) {
         $shipment->setWeight(\SimpleUPS\Weight::fromXml($xml->ShipmentWeight));
     }
     if (isset($xml->ShipmentIdentificationNumber)) {
         $shipment->setShipmentIdentificationNumber($xml->ShipmentIdentificationNumber);
     }
     return $shipment;
 }
Ejemplo n.º 2
0
 /**
  * @internal
  *
  * @param \SimpleXMLElement $xml
  *
  * @return Shipment
  */
 public static function fromXml(\SimpleXMLElement $xml)
 {
     $shipment = new Shipment();
     $shipment->setIsResponse();
     if (isset($xml->Shipper)) {
         $shipment->setShipper(Shipper::fromXml($xml->Shipper));
     }
     if (isset($xml->ShipTo->Address)) {
         $shipment->setDestination(InstructionalAddress::fromXml($xml->ShipTo->Address));
     }
     if (isset($xml->Package)) {
         foreach ($xml->Package as $package) {
             $shipment->addPackage(Package::fromXml($package));
         }
     }
     if (isset($xml->Service)) {
         $shipment->setService(Service::fromXml($xml->Service));
     }
     return $shipment;
 }