Exemplo n.º 1
0
 /**
  * Tests the toArray method
  */
 public function testToArray()
 {
     $request = new GetContactRequest();
     $request->setRequestFilter(new RequestFilter('*****@*****.**'));
     $expected = array('AllFields' => true, 'Interest' => true, 'LastModifiedOnly' => false, 'Offset' => 0, 'RequestFilter' => array('Email' => '*****@*****.**', 'MemberID' => null), 'ReturnFields' => array());
     $this->assertEquals($expected, $request->toArray());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getContacts(GetContactRequest $request = null)
 {
     if (!$request) {
         $request = new GetContactRequest();
     }
     $try = 0;
     while (true) {
         $try++;
         try {
             $response = $this->soapClient->__soapCall('GetContact', array(array('token' => $this->authenticationManager->getAuthenticationTokenContext()->toArray(), 'request' => $request->toArray())));
             $contacts = new GetContactResponse();
             foreach ($response->GetContactResult->ContactList->ContactData as $contactData) {
                 $contact = new ContactData();
                 foreach ($contactData->CustomFields->CustomField as $customField) {
                     $field = new CustomField();
                     $field->setCustomName($customField->CustomName);
                     $field->setFieldType($customField->FieldType);
                     $field->setName($customField->Name);
                     $field->setValue($customField->Value);
                     $contact->addCustomField($field);
                 }
                 $contact->setEmail($contactData->Email);
                 $contact->setError($contactData->Error);
                 if (property_exists($contactData->Interests, 'Interest')) {
                     $contactInterest = $contactData->Interests->Interest;
                     $interest = new Interest();
                     $interest->setGroup(new InterestGroup($contactInterest->Group->Id, $contactInterest->Group->Name));
                     $interest->setInterestDate(new \DateTime($contactInterest->InterestDate));
                     $interest->setValue(new InterestValue($contactInterest->Value->Id, $contactInterest->Value->Name));
                     $contact->addInterest($interest);
                 }
                 $contact->setMemberId($contactData->MemberId);
                 $contact->setOptoutEmail($contactData->OptoutEmail);
                 $contact->setOptoutMobile($contactData->OptoutMobile);
                 $contact->setReadOnly($contactData->ReadOnly);
                 $contact->setStatus($contactData->Status);
                 $contact->setSubscribeDate(new \DateTime($contactData->SubscribeDate));
                 $contact->setUnsubscribeDate(new \DateTime($contactData->UnsubscribeDate));
                 $contact->setUpdateDate(new \DateTime($contactData->UpdateDate));
                 $contacts->addContact($contact);
             }
             $contacts->setReturnContactsCount($response->GetContactResult->ReturnContactsCount);
             $contacts->setTotalContactsCount($response->GetContactResult->TotalContactsCount);
             return $contacts;
         } 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);
         }
     }
 }