Ejemplo n.º 1
0
 /**
  * Test some missing stuff to get full coverage
  */
 public function testMissingProperties()
 {
     $data = array('IsComfortZoneUser' => true, 'OptIn' => true, 'UseInformationForThirdParty' => false, 'UserName' => 'UserName', 'PackStations' => array('Foo', 'Bar'));
     $customer = new Customer();
     $customer->setIsComfortZoneUser($data['IsComfortZoneUser']);
     $this->assertEquals($data['IsComfortZoneUser'], $customer->getIsComfortZoneUser());
     $customer->setOptIn($data['OptIn']);
     $this->assertEquals($data['OptIn'], $customer->getOptIn());
     $customer->setUseInformationForThirdParty($data['UseInformationForThirdParty']);
     $this->assertEquals($data['UseInformationForThirdParty'], $customer->getUseInformationForThirdParty());
     $customer->setUserName($data['UserName']);
     $this->assertEquals($data['UserName'], $customer->getUserName());
     $customer->setPackStations($data['PackStations']);
     $this->assertEquals($data['PackStations'], $customer->getPackStations());
 }
Ejemplo n.º 2
0
 /**
  * Retrieve member information
  *
  * @param  string   $id
  * @param  boolean  $as_xml [optional]
  * @return Customer / mixed
  */
 public function getMember($id, $as_xml = false)
 {
     $xml = $this->doCall('/customer/' . $id);
     if ($as_xml) {
         return $xml;
     }
     return Customer::createFromXML($xml);
 }
Ejemplo n.º 3
0
 /**
  * @param  \SimpleXMLElement $xml
  * @return Customer
  */
 public static function createFromXML(\SimpleXMLElement $xml)
 {
     // @todo work with classmaps ...
     if (!isset($xml->UserID)) {
         throw new Exception('No UserId found.');
     }
     $customer = new Customer();
     if (isset($xml->UserID) && $xml->UserID != '') {
         $customer->setUserID((string) $xml->UserID);
     }
     if (isset($xml->FirstName) && $xml->FirstName != '') {
         $customer->setFirstName((string) $xml->FirstName);
     }
     if (isset($xml->LastName) && $xml->LastName != '') {
         $customer->setLastName((string) $xml->LastName);
     }
     if (isset($xml->Street) && $xml->Street != '') {
         $customer->setStreet((string) $xml->Street);
     }
     if (isset($xml->Number) && $xml->Number != '') {
         $customer->setNumber((string) $xml->Number);
     }
     if (isset($xml->CompanyName) && $xml->CompanyName != '') {
         $customer->setCompanyName((string) $xml->CompanyName);
     }
     if (isset($xml->DateOfBirth) && $xml->DateOfBirth != '') {
         $dateTime = new \DateTime((string) $xml->DateOfBirth);
         $customer->setDateOfBirth($dateTime);
     }
     if (isset($xml->DeliveryCode) && $xml->DeliveryCode != '') {
         $customer->setDeliveryCode((string) $xml->DeliveryCode);
     }
     if (isset($xml->Email) && $xml->Email != '') {
         $customer->setEmail((string) $xml->Email);
     }
     if (isset($xml->MobilePrefix) && $xml->MobilePrefix != '') {
         $customer->setMobilePrefix(trim((string) $xml->MobilePrefix));
     }
     if (isset($xml->MobileNumber) && $xml->MobileNumber != '') {
         $customer->setMobileNumber((string) $xml->MobileNumber);
     }
     if (isset($xml->Postalcode) && $xml->Postalcode != '') {
         $customer->setPostalCode((string) $xml->Postalcode);
     }
     if (isset($xml->PreferredLanguage) && $xml->PreferredLanguage != '') {
         $customer->setPreferredLanguage((string) $xml->PreferredLanguage);
     }
     if (isset($xml->ReceivePromotions) && $xml->ReceivePromotions != '') {
         $receivePromotions = in_array((string) $xml->ReceivePromotions, array('true', '1'));
         $customer->setReceivePromotions($receivePromotions);
     }
     if (isset($xml->actived) && $xml->actived != '') {
         $activated = in_array((string) $xml->actived, array('true', '1'));
         $customer->setActivated($activated);
     }
     if (isset($xml->Title) && $xml->Title != '') {
         $title = (string) $xml->Title;
         $title = ucfirst(strtolower($title));
         if (substr($title, -1) != '.') {
             $title .= '.';
         }
         $customer->setTitle($title);
     }
     if (isset($xml->Town) && $xml->Town != '') {
         $customer->setTown((string) $xml->Town);
     }
     if (isset($xml->PackStations->CustomerPackStation)) {
         foreach ($xml->PackStations->CustomerPackStation as $packStation) {
             $customer->addPackStation(CustomerPackStation::createFromXML($packStation));
         }
     }
     return $customer;
 }
Ejemplo n.º 4
0
 /**
  * Retrieve member information
  *
  * @param  string   $id
  * @return Customer
  */
 public function getMember($id)
 {
     $xml = $this->doCall('/customer/' . $id);
     return Customer::createFromXML($xml);
 }