Ejemplo n.º 1
0
 /**
  * @internal
  *
  * @param \SimpleXMLElement $xml
  *
  * @return ShippingMethod
  */
 public static function fromXml(\SimpleXMLElement $xml)
 {
     $shippingMethod = new ShippingMethod();
     $shippingMethod->setIsResponse();
     $shippingMethod->setService(Service::fromXml($xml->Service));
     if (isset($xml->TotalCharges->MonetaryValue)) {
         $shippingMethod->setTotalCharges($xml->TotalCharges->MonetaryValue);
     }
     if (isset($xml->TransportationCharges->MonetaryValue)) {
         $shippingMethod->setTransportationCharges($xml->TransportationCharges->MonetaryValue);
     }
     if (isset($xml->ServiceOptionsCharges->MonetaryValue)) {
         $shippingMethod->setServiceOptionsCharges($xml->ServiceOptionsCharges->MonetaryValue);
     }
     if (isset($xml->GuaranteedDaysToDelivery) && is_numeric($xml->GuaranteedDaysToDelivery)) {
         $shippingMethod->setGuaranteedDaysToDelivery($xml->GuaranteedDaysToDelivery);
     }
     if (isset($xml->ScheduledDeliveryTime)) {
         $shippingMethod->setScheduledDeliveryTime(new \DateTime($xml->ScheduledDeliveryTime));
     }
     return $shippingMethod;
 }
Ejemplo n.º 2
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.º 3
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;
 }