Example #1
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return At247
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $at247 = new At247();
     if (isset($xml->{'at24-7'}->product) && $xml->{'at24-7'}->product != '') {
         $at247->setProduct((string) $xml->{'at24-7'}->product);
     }
     if (isset($xml->{'at24-7'}->options)) {
         foreach ($xml->{'at24-7'}->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed'))) {
                 $option = Messaging::createFromXML($optionData);
             } else {
                 $className = '\\TijsVerkoyen\\Bpost\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
                 if (!method_exists($className, 'createFromXML')) {
                     throw new Exception('Not Implemented');
                 }
                 $option = call_user_func(array($className, 'createFromXML'), $optionData);
             }
             $at247->addOption($option);
         }
     }
     if (isset($xml->{'at24-7'}->weight) && $xml->{'at24-7'}->weight != '') {
         $at247->setWeight((int) $xml->{'at24-7'}->weight);
     }
     if (isset($xml->{'at24-7'}->memberId) && $xml->{'at24-7'}->memberId != '') {
         $at247->setMemberId((string) $xml->{'at24-7'}->memberId);
     }
     if (isset($xml->{'at24-7'}->receiverName) && $xml->{'at24-7'}->receiverName != '') {
         $at247->setReceiverName((string) $xml->{'at24-7'}->receiverName);
     }
     if (isset($xml->{'at24-7'}->receiverCompany) && $xml->{'at24-7'}->receiverCompany != '') {
         $at247->setReceiverCompany((string) $xml->{'at24-7'}->receiverCompany);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotId) && $xml->{'at24-7'}->parcelsDepotId != '') {
         $at247->setParcelsDepotId((string) $xml->{'at24-7'}->parcelsDepotId);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotName) && $xml->{'at24-7'}->parcelsDepotName != '') {
         $at247->setParcelsDepotName((string) $xml->{'at24-7'}->parcelsDepotName);
     }
     if (isset($xml->{'at24-7'}->parcelsDepotAddress)) {
         $parcelsDepotAddressData = $xml->{'at24-7'}->parcelsDepotAddress->children('http://schema.post.be/shm/deepintegration/v3/common');
         $at247->setParcelsDepotAddress(ParcelsDepotAddress::createFromXML($parcelsDepotAddressData));
     }
     return $at247;
 }
Example #2
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return International
  */
 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)) {
         foreach ($xml->international->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed'))) {
                 $option = Messaging::createFromXML($optionData);
             } else {
                 $className = '\\TijsVerkoyen\\Bpost\\Bpost\\Order\\Box\\Option\\' . ucfirst($optionData->getName());
                 if (!method_exists($className, 'createFromXML')) {
                     throw new Exception('Not Implemented');
                 }
                 $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;
 }