/**
  * @param  \SimpleXMLElement $xml
  *
  * @return CustomsInfo
  * @throws BpostInvalidLengthException
  * @throws BpostInvalidValueException
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $customsInfo = new CustomsInfo();
     if (isset($xml->parcelValue) && $xml->parcelValue != '') {
         $customsInfo->setParcelValue((int) $xml->parcelValue);
     }
     if (isset($xml->contentDescription) && $xml->contentDescription != '') {
         $customsInfo->setContentDescription((string) $xml->contentDescription);
     }
     if (isset($xml->shipmentType) && $xml->shipmentType != '') {
         $customsInfo->setShipmentType((string) $xml->shipmentType);
     }
     if (isset($xml->parcelReturnInstructions) && $xml->parcelReturnInstructions != '') {
         $customsInfo->setParcelReturnInstructions((string) $xml->parcelReturnInstructions);
     }
     if (isset($xml->privateAddress) && $xml->privateAddress != '') {
         $customsInfo->setPrivateAddress((string) $xml->privateAddress == 'true');
     }
     return $customsInfo;
 }
 /**
  * @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;
 }