예제 #1
0
 /**
  * Test validation in the setters
  */
 public function testFaultyProperties()
 {
     $atBpost = new AtBpost();
     try {
         $atBpost->setProduct(str_repeat('a', 10));
     } catch (\Exception $e) {
         $this->assertInstanceOf('TijsVerkoyen\\Bpost\\Exception', $e);
         $this->assertEquals(sprintf('Invalid value, possible values are: %1$s.', implode(', ', AtBpost::getPossibleProductValues())), $e->getMessage());
     }
 }
예제 #2
0
파일: AtBpost.php 프로젝트: BenCavens/bpost
 /**
  * @param  \SimpleXMLElement $xml
  * @return AtBpost
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     $atBpost = new AtBpost();
     if (isset($xml->atBpost->product) && $xml->atBpost->product != '') {
         $atBpost->setProduct((string) $xml->atBpost->product);
     }
     if (isset($xml->atBpost->options)) {
         foreach ($xml->atBpost->options as $optionData) {
             $optionData = $optionData->children('http://schema.post.be/shm/deepintegration/v3/common');
             if (in_array($optionData->getName(), array('infoDistributed', 'infoNextDay', 'infoReminder', 'keepMeInformed'))) {
                 $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);
             }
             $atBpost->addOption($option);
         }
     }
     if (isset($xml->atBpost->weight) && $xml->atBpost->weight != '') {
         $atBpost->setWeight((int) $xml->atBpost->weight);
     }
     if (isset($xml->atBpost->receiverName) && $xml->atBpost->receiverName != '') {
         $atBpost->setReceiverName((string) $xml->atBpost->receiverName);
     }
     if (isset($xml->atBpost->receiverCompany) && $xml->atBpost->receiverCompany != '') {
         $atBpost->setReceiverCompany((string) $xml->atBpost->receiverCompany);
     }
     if (isset($xml->atBpost->pugoId) && $xml->atBpost->pugoId != '') {
         $atBpost->setPugoId((string) $xml->atBpost->pugoId);
     }
     if (isset($xml->atBpost->pugoName) && $xml->atBpost->pugoName != '') {
         $atBpost->setPugoName((string) $xml->atBpost->pugoName);
     }
     if (isset($xml->atBpost->pugoAddress)) {
         $pugoAddressData = $xml->atBpost->pugoAddress->children('http://schema.post.be/shm/deepintegration/v3/common');
         $atBpost->setPugoAddress(PugoAddress::createFromXML($pugoAddressData));
     }
     return $atBpost;
 }
예제 #3
0
파일: index.php 프로젝트: BenCavens/bpost
//    'BE19210023508812',
//    'GEBABEBB'
//);
//$option = new Signature();
//$option = new Insurance('additionalInsurance', 3);
//$option = new AutomaticSecondPresentation();
// @Home
$atHome = new AtHome();
$atHome->setProduct('bpack 24h Pro');
$atHome->setWeight(2000);
$atHome->setReceiver($receiver);
$atHome->addOption($option);
$box->setNationalBox($atHome);
// @Bpost
$pugoAddress = new PugoAddress('Turnhoutsebaan', '468', null, '2110', 'Wijnegem', 'BE');
$atBpost = new AtBpost();
$atBpost->setWeight(2000);
$atBpost->setPugoId('207500');
$atBpost->setPugoName('WIJNEGEM');
$atBpost->setPugoAddress($pugoAddress);
$atBpost->setReceiverName('Tijs Verkoyen');
$atBpost->setReceiverCompany('Sumo Coders');
//$box->setNationalBox($atBpost);
// @24/7
$parcelsDepotAddress = new ParcelsDepotAddress('Turnhoutsebaan', '468', null, '2110', 'Wijnegem', 'BE');
$parcelsDepotAddress->setBox('A');
$at247 = new At247();
$at247->setParcelsDepotId('014472');
$at247->setParcelsDepotName('WIJNEGEM');
$at247->setParcelsDepotAddress($parcelsDepotAddress);
$at247->setMemberId('188565346');