Ejemplo n.º 1
0
 /**
  * The GetServicePointDetails web service delivers the details for a bpost
  * pick up point referred to by its identifier.
  *
  * @param string $id       Requested point identifier
  * @param string $language Language, possible values: nl, fr
  * @param int    $type     Requested point type, possible values are:
  *                         - 1: Post Office
  *                         - 2: Post Point
  *                         - 4: bpack 24/7
  *
  * @return Poi
  * @throws BpostCurlException
  * @throws BpostInvalidXmlResponseException
  * @throws BpostTaxipostLocatorException
  */
 public function getServicePointDetails($id, $language = 'nl', $type = 3)
 {
     $parameters = array('Id' => (string) $id, 'Language' => (string) $language, 'Type' => (int) $type);
     $xml = $this->doCall('info', $parameters);
     if (!isset($xml->Poi)) {
         throw new BpostInvalidXmlResponseException();
     }
     return Poi::createFromXML($xml->Poi);
 }
Ejemplo n.º 2
0
 /**
  * Create a POI based on an XML-object
  *
  * @param  \SimpleXMLElement $xml
  * @return Poi
  * @throws BpostInvalidXmlResponseException
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     if (!isset($xml->Record)) {
         throw new BpostInvalidXmlResponseException('"Record" missing');
     }
     $recordXml = $xml->Record;
     $poi = new Poi();
     if (isset($recordXml->Id) && $recordXml->Id != '') {
         $poi->setId((string) $recordXml->Id);
     }
     if (isset($recordXml->ID) && $recordXml->ID != '') {
         $poi->setId((string) $recordXml->ID);
     }
     if (isset($recordXml->Type) && $recordXml->Type != '') {
         $poi->setType((string) $recordXml->Type);
     }
     if (isset($recordXml->Name) && $recordXml->Name != '') {
         $poi->setOffice((string) $recordXml->Name);
     }
     if (isset($recordXml->OFFICE) && $recordXml->OFFICE != '') {
         $poi->setOffice((string) $recordXml->OFFICE);
     }
     if (isset($recordXml->Street) && $recordXml->Street != '') {
         $poi->setStreet((string) $recordXml->Street);
     }
     if (isset($recordXml->STREET) && $recordXml->STREET != '') {
         $poi->setStreet((string) $recordXml->STREET);
     }
     if (isset($recordXml->Number) && $recordXml->Number != '') {
         $poi->setNr((string) $recordXml->Number);
     }
     if (isset($recordXml->NR) && $recordXml->NR != '') {
         $poi->setNr((string) $recordXml->NR);
     }
     if (isset($recordXml->Zip) && $recordXml->Zip != '') {
         $poi->setZip((string) $recordXml->Zip);
     }
     if (isset($recordXml->ZIP) && $recordXml->ZIP != '') {
         $poi->setZip((string) $recordXml->ZIP);
     }
     if (isset($recordXml->City) && $recordXml->City != '') {
         $poi->setCity((string) $recordXml->City);
     }
     if (isset($recordXml->CITY) && $recordXml->CITY != '') {
         $poi->setCity((string) $recordXml->CITY);
     }
     if (isset($recordXml->X) && $recordXml->X != '') {
         $poi->setX((int) $recordXml->X);
     }
     if (isset($recordXml->Y) && $recordXml->Y != '') {
         $poi->setY((int) $recordXml->Y);
     }
     if (isset($recordXml->Longitude) && $recordXml->Longitude != '') {
         $poi->setLongitude((double) $recordXml->Longitude);
     }
     if (isset($recordXml->Latitude) && $recordXml->Latitude != '') {
         $poi->setLatitude((double) $recordXml->Latitude);
     }
     if (isset($recordXml->Services) && isset($recordXml->Services->Service)) {
         foreach ($recordXml->Services->Service as $service) {
             $poi->addService(Service::createFromXML($service));
         }
     }
     if (isset($recordXml->Hours)) {
         $recordHoursXml = $recordXml->Hours;
         if (isset($recordHoursXml->Monday)) {
             $poi->addHour(Day::DAY_INDEX_MONDAY, Day::createFromXML($recordHoursXml->Monday));
         }
         if (isset($recordHoursXml->Tuesday)) {
             $poi->addHour(Day::DAY_INDEX_TUESDAY, Day::createFromXML($recordHoursXml->Tuesday));
         }
         if (isset($recordHoursXml->Wednesday)) {
             $poi->addHour(Day::DAY_INDEX_WEDNESDAY, Day::createFromXML($recordHoursXml->Wednesday));
         }
         if (isset($recordHoursXml->Thursday)) {
             $poi->addHour(Day::DAY_INDEX_THURSDAY, Day::createFromXML($recordHoursXml->Thursday));
         }
         if (isset($recordHoursXml->Friday)) {
             $poi->addHour(Day::DAY_INDEX_FRIDAY, Day::createFromXML($recordHoursXml->Friday));
         }
         if (isset($recordHoursXml->Saturday)) {
             $poi->addHour(Day::DAY_INDEX_SATURDAY, Day::createFromXML($recordHoursXml->Saturday));
         }
         if (isset($recordHoursXml->Sunday)) {
             $poi->addHour(Day::DAY_INDEX_SUNDAY, Day::createFromXML($recordHoursXml->Sunday));
         }
     }
     if (isset($recordXml->ClosedFrom) && $recordXml->ClosedFrom != '') {
         $poi->setClosedFrom((string) $recordXml->ClosedFrom);
     }
     if (isset($recordXml->ClosedTo) && $recordXml->ClosedTo != '') {
         $poi->setClosedTo((string) $recordXml->ClosedTo);
     }
     if (isset($recordXml->NOTE) && $recordXml->NOTE != '') {
         $poi->setNote((string) $recordXml->NOTE);
     }
     if (isset($xml->Page) && isset($xml->Page['ServiceRef']) && $xml->Page['ServiceRef'] != '') {
         $poi->setPage($xml->Page['ServiceRef']);
     }
     return $poi;
 }