/**
  * @param  \SimpleXMLElement $xml
  * @return BpostOnAppointment
  * @throws BpostXmlInvalidItemException
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $self = new self();
     if (!isset($xml->bpostOnAppointment)) {
         throw new BpostXmlInvalidItemException();
     }
     $bpostOnAppointmentXml = $xml->bpostOnAppointment;
     if (isset($bpostOnAppointmentXml->receiver)) {
         $self->setReceiver(Receiver::createFromXML($bpostOnAppointmentXml->receiver->children('http://schema.post.be/shm/deepintegration/v3/common')));
     }
     if (isset($bpostOnAppointmentXml->inNetworkCutOff) && $bpostOnAppointmentXml->inNetworkCutOff != '') {
         $self->setInNetworkCutOff((string) $bpostOnAppointmentXml->inNetworkCutOff);
     }
     return $self;
 }
 /**
  * @param  \SimpleXMLElement $xml
  *
  * @return International
  * @throws BpostInvalidValueException
  * @throws BpostNotImplementedException
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $international = new International();
     if (isset($xml->international->product) && $xml->international->product != '') {
         $international->setProduct((string) $xml->international->product);
     }
     if (isset($xml->international->options)) {
         /** @var \SimpleXMLElement $optionData */
         foreach ($xml->international->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array(Messaging::MESSAGING_TYPE_INFO_DISTRIBUTED))) {
                 $option = Messaging::createFromXML($optionData);
             } else {
                 $className = '\\Bpost\\BpostApiClient\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
                 if (!method_exists($className, 'createFromXML')) {
                     throw new BpostNotImplementedException();
                 }
                 $option = call_user_func(array($className, 'createFromXML'), $optionData);
             }
             $international->addOption($option);
         }
     }
     if (isset($xml->international->parcelWeight) && $xml->international->parcelWeight != '') {
         $international->setParcelWeight((int) $xml->international->parcelWeight);
     }
     if (isset($xml->international->receiver)) {
         $receiverData = $xml->international->receiver->children('http://schema.post.be/shm/deepintegration/v3/common');
         $international->setReceiver(Receiver::createFromXML($receiverData));
     }
     if (isset($xml->international->customsInfo)) {
         $international->setCustomsInfo(CustomsInfo::createFromXML($xml->international->customsInfo));
     }
     return $international;
 }
示例#3
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return AtHome
  * @throws BpostNotImplementedException
  * @throws BpostXmlInvalidItemException
  * @throws \Bpost\BpostApiClient\BpostException
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $self = new self();
     if (!isset($xml->atHome)) {
         throw new BpostXmlInvalidItemException();
     }
     $atHomeXml = $xml->atHome[0];
     $self = parent::createFromXML($atHomeXml, $self);
     if (isset($atHomeXml->receiver)) {
         $self->setReceiver(Receiver::createFromXML($atHomeXml->receiver->children('http://schema.post.be/shm/deepintegration/v3/common')));
     }
     if (isset($atHomeXml->requestedDeliveryDate) && $atHomeXml->requestedDeliveryDate != '') {
         $self->setRequestedDeliveryDate($atHomeXml->requestedDeliveryDate);
     }
     return $self;
 }