예제 #1
0
 /**
  * Tests the toArray method
  */
 public function testToArray()
 {
     $contact = new Contact();
     $contact->setEmail('*****@*****.**');
     $contact->addField(new Field('firstname', 'Rémi'));
     $contact->addField(new Field('lastname', 'Marseille'));
     $contact->setInterestsToAdd(array(1, 2));
     $contact->setInterestsToDelete(array(3, 4));
     $contact->setOptoutEmail(1);
     $contact->setOptoutMobile(1);
     $expected = array('Email' => '*****@*****.**', 'Fields' => array(array('Name' => 'firstname', 'Value' => 'Rémi'), array('Name' => 'lastname', 'Value' => 'Marseille')), 'InterestsToAdd' => array(1, 2), 'InterestsToDelete' => array(3, 4), 'OptoutEmail' => 1, 'OptoutMobile' => 1);
     $this->assertEquals($expected, $contact->toArray());
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function save(Contact $contact)
 {
     $try = 0;
     while (true) {
         $try++;
         try {
             $response = $this->soapClient->__soapCall('SaveContact', array(array('token' => $this->authenticationManager->getAuthenticationTokenContext()->toArray(), 'contact' => $contact->toArray())));
             return $response->SaveContactResult;
         } catch (\SoapFault $e) {
             if (null !== $this->logger) {
                 $this->logger->critical(sprintf('[%] %s', __CLASS__, $e->getMessage()));
             }
             if ($try >= $this->retries) {
                 throw $e;
             }
             // waiting 500ms before next call
             usleep(500000);
         }
     }
 }