Overview

Namespaces

  • Ctct
    • Auth
    • Components
      • Account
      • Activities
      • Contacts
      • EmailMarketing
      • Tracking
    • Exceptions
    • Services
  • PHP

Classes

  • ConstantContact
  • SplClassLoader
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: namespace Ctct;
  3: 
  4: use Ctct\Services\BaseService;
  5: use Ctct\Services\AccountService;
  6: use Ctct\Services\ContactService;
  7: use Ctct\Services\ListService;
  8: use Ctct\Services\EmailMarketingService;
  9: use Ctct\Services\CampaignScheduleService;
 10: use Ctct\Services\CampaignTrackingService;
 11: use Ctct\Services\ContactTrackingService;
 12: use Ctct\Services\ActivityService;
 13: use Ctct\Components\Account\VerifiedEmailAddress;
 14: use Ctct\Components\Contacts\Contact;
 15: use Ctct\Components\Contacts\ContactList;
 16: use Ctct\Components\EmailMarketing\Campaign;
 17: use Ctct\Components\EmailMarketing\Schedule;
 18: use Ctct\Components\EmailMarketing\TestSend;
 19: use Ctct\Components\Tracking\TrackingSummary;
 20: use Ctct\Components\Tracking\TrackingActivity;
 21: use Ctct\Components\Activities\AddContacts;
 22: use Ctct\Components\Activities\ExportContacts;
 23: use Ctct\Exceptions\CtctException;
 24: use Ctct\Exceptions\IllegalArgumentException;
 25: use Ctct\Util\Config;
 26: use Ctct\Components\ResultSet;
 27: 
 28: /**
 29:  * Exposes all implemented Constant Contact API functionality
 30:  *
 31:  * @package Ctct
 32:  * @version 1.1.0
 33:  * @author Constant Contact
 34:  */
 35: class ConstantContact
 36: {
 37:     /**
 38:      * Constant Contact API Key
 39:      * @var string
 40:      */
 41:     private $apiKey;
 42: 
 43:     /**
 44:      * ContactService for handling interaction with contact management
 45:      * @var ContactService
 46:      */
 47:     protected $contactService;
 48: 
 49:     /**
 50:      * EmailMarketingService for handling interaction with email marketing
 51:      * @var CampaignService
 52:      */
 53:     protected $emailMarketingService;
 54: 
 55:     /**
 56:      * ListService for handling interaction with contact list management
 57:      * @var ListService
 58:      */
 59:     protected $listService;
 60: 
 61:     /**
 62:      * ActivityService for handling interaction with bulk activities
 63:      * @var ActivityService
 64:      */
 65:     protected $activityService;
 66: 
 67:     /**
 68:      * CampaignTrackingService for handling interaction with email marketing tracking
 69:      * @var CampaignTrackingService
 70:      */
 71:     protected $campaignTrackingService;
 72: 
 73:     /**
 74:      * ContactTrackingService for handling interaction with contact tracking
 75:      * @var ContactTrackingService
 76:      */
 77:     protected $contactTrackingService;
 78: 
 79:     /**
 80:      * CampaignScheduleService for handling interaction with email marketing campaign scheduling
 81:      * @var CampaignScheduleService
 82:      */
 83:     protected $campaignScheduleService;
 84: 
 85:     /**
 86:      * AccountService for handling interaction with account management
 87:      * @var AccountService
 88:      */
 89:     protected $accountService;
 90: 
 91:     /**
 92:      * Class constructor
 93:      * Registers the API key with the ConstantContact class that will be used for all API calls.
 94:      * @param string $apiKey - Constant Contact API Key
 95:      */
 96:     public function __construct($apiKey)
 97:     {
 98:         $this->apiKey = $apiKey;
 99:         $this->contactService = new ContactService($apiKey);
100:         $this->emailMarketingService = new EmailMarketingService($apiKey);
101:         $this->activityService = new ActivityService($apiKey);
102:         $this->campaignTrackingService = new CampaignTrackingService($apiKey);
103:         $this->contactTrackingService = new ContactTrackingService($apiKey);
104:         $this->campaignScheduleService = new CampaignScheduleService($apiKey);
105:         $this->listService = new ListService($apiKey);
106:         $this->accountService = new AccountService($apiKey);
107:     }
108:     
109:     /**
110:      * Get a set of campaigns
111:      * @param string $accessToken - Constant Contact OAuth2 access token
112:      * @param mixed $params - associative array of query parameters and values to append to the request. 
113:      *      Allow parameters include:
114:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
115:      *      modified_since - ISO-8601 formatted timestamp.
116:      *      next - the next link returned from a previous paginated call. May only be used by itself.
117:      *      email - the contact by email address to retrieve information for
118:      * @return ResultSet containing a results array of {@link Ctct\Components\Contacts\Contact}
119:      */
120:     public function getContacts($accessToken, array $params = array())
121:     {
122:         return $this->contactService->getContacts($accessToken, $params);
123:     }
124:     
125:     /**
126:      * Get an individual contact
127:      * @param string $accessToken - Valid access token
128:      * @param int $contactId - Id of the contact to retrieve
129:      * @return Contact
130:      */
131:     public function getContact($accessToken, $contactId)
132:     {
133:         return $this->contactService->getContact($accessToken, $contactId);
134:     }
135:     
136:     /**
137:      * Get contacts with a specified email eaddress
138:      * @param string $accessToken - Constant Contact OAuth2 access token
139:      * @param string $email - contact email address to search for
140:      * @return array
141:      */
142:     public function getContactByEmail($accessToken, $email)
143:     {
144:         return $this->contactService->getContacts($accessToken, array('email' => $email));
145:     }
146:     
147:     /**
148:      * Add a new contact to an account
149:      * @param string $accessToken - Valid access token
150:      * @param Contact $contact - Contact to add
151:      * @param boolean $actionByVisitor - is the action being taken by the visitor 
152:      * @return Contact
153:      */
154:     public function addContact($accessToken, Contact $contact, $actionByVisitor = false)
155:     {
156:         $params = array();
157:         if ($actionByVisitor == true) {
158:             $params['action_by'] = "ACTION_BY_VISITOR";
159:         }
160:         return $this->contactService->addContact($accessToken, $contact, $params);
161:     }
162:     
163:     /**
164:      * Sets an individual contact to 'REMOVED' status
165:      * @param string $accessToken - Valid access token
166:      * @param mixed $contact - Either a Contact id or the Contact itself
167:      * @throws IllegalArgumentException - if an int or Contact object is not provided
168:      * @return boolean
169:      */
170:     public function deleteContact($accessToken, $contact)
171:     {
172:         $contactId = $this->getArgumentId($contact, 'Contact');
173:         return $this->contactService->deleteContact($accessToken, $contactId);
174:     }
175:     
176:     /**
177:      * Delete a contact from all contact lists
178:      * @param string $accessToken - Constant Contact OAuth2 access token
179:      * @param mixed $contact - Contact id or the Contact object itself
180:      * @throws IllegalArgumentException - if an int or Contact object is not provided
181:      * @return boolean
182:      */
183:     public function deleteContactFromLists($accessToken, $contact)
184:     {
185:         $contactId = $this->getArgumentId($contact, 'Contact');
186:         return $this->contactService->deleteContactFromLists($accessToken, $contactId);
187:     }
188: 
189:     /**
190:      * Delete a contact from all contact lists
191:      * @param string $accessToken - Constant Contact OAuth2 access token
192:      * @param mixed $contact - Contact id or a Contact object
193:      * @param mixed $list - ContactList id or a ContactList object
194:      * @throws IllegalArgumentException - if an int or Contact object is not provided, 
195:      * as well as an int or ContactList object
196:      * @return boolean
197:      */
198:     public function deleteContactFromList($accessToken, $contact, $list)
199:     {
200:         $contactId = $this->getArgumentId($contact, 'Contact');
201:         $listId = $this->getArgumentId($list, 'ContactList');
202:         
203:         return $this->contactService->deleteContactFromList($accessToken, $contactId, $listId);
204:     }
205:     
206:     /**
207:      * Update an individual contact
208:      * @param string $accessToken - Valid access token
209:      * @param Contact $contact - Contact to update
210:      * @param boolean $actionByVisitor - is the action being taken by the visitor, default is false  
211:      * @return Contact
212:      */
213:     public function updateContact($accessToken, Contact $contact, $actionByVisitor = false)
214:     {
215:         $params = array();
216:         if ($actionByVisitor == true) {
217:             $params['action_by'] = "ACTION_BY_VISITOR";
218:         }
219:         return $this->contactService->updateContact($accessToken, $contact, $params);
220:     }
221:     
222:     /**
223:      * Get lists
224:      * @param string $accessToken - Valid access token
225:      * @param string $date - ISO-8601 date to query by
226:      * @return array
227:      */
228:     public function getLists($accessToken, array $params = array())
229:     {
230:         return $this->listService->getLists($accessToken, $params);
231:     }
232: 
233:     /**
234:      * Get an individual list
235:      * @param string $accessToken - Valid access token
236:      * @param int $listId - Id of the list to retrieve
237:      * @return ContactList
238:      */
239:     public function getList($accessToken, $listId)
240:     {
241:         return $this->listService->getList($accessToken, $listId);
242:     }
243:     
244:     /**
245:      * Add a new contact list to an account
246:      * @param string $accessToken - Valid access token
247:      * @param ContactList $list - List to add
248:      * @return ContactList
249:      */
250:     public function addList($accessToken, ContactList $list)
251:     {
252:         return $this->listService->addList($accessToken, $list);
253:     }
254:     
255:     /**
256:      * Update a contact list
257:      * @param string $accessToken - Valid access token
258:      * @param ContactList $list - ContactList to update
259:      * @return ContactList
260:      */
261:     public function updateList($accessToken, ContactList $list)
262:     {
263:         return $this->listService->updateList($accessToken, $list);
264:     }
265: 
266:     /**
267:      * Get contact that belong to a specific list
268:      * @param string $accessToken - Constant Contact OAuth2 access token
269:      * @param mixed $list - Id of the list or a ContactList object
270:      * @param mixed $param - denotes the number of results per set, limited to 50, or a next parameter provided
271:      * from a previous getContactsFromList call
272:      * @return array
273:      * @throws IllegalArgumentException - if a ContactList object or id is not passed
274:      */
275:     public function getContactsFromList($accessToken, $list, $param = null)
276:     {
277:         $listId = $this->getArgumentId($list, 'ContactList');
278:         $param = $this->determineParam($param);
279:         return $this->listService->getContactsFromList($accessToken, $listId, $param);
280:     }
281:     
282:     /**
283:      * Get a set of campaigns
284:      * @param string $accessToken - Constant Contact OAuth2 access token
285:      * @param mixed $params - associative array of query parameters and values to append to the request. 
286:      *      Allow parameters include:
287:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
288:      *      modified_since - ISO-8601 formatted timestamp.
289:      *      next - the next link returned from a previous paginated call. May only be used by itself.
290:      *      email - the contact by email address to retrieve information for
291:      * @return ResultSet containing a results array of {@link Ctct\Components\EmailMarketing\Campaign}
292:      */
293:     public function getEmailCampaigns($accessToken, array $params = array())
294:     {
295:         return $this->emailMarketingService->getCampaigns($accessToken, $params);
296:     }
297:     
298:     /**
299:      * Get an individual campaign
300:      * @param string $accessToken - Constant Contact OAuth2 access token
301:      * @param int $campaignId - Valid campaign id
302:      */
303:     public function getEmailCampaign($accessToken, $campaignId)
304:     {
305:         return $this->emailMarketingService->getCampaign($accessToken, $campaignId);
306:     }
307:     
308:     /**
309:      * Delete an individual campaign
310:      * @param string $accessToken - Constant Contact OAuth2 access token
311:      * @param mixed $campaign - Id of a campaign or a Campaign object itself
312:      * @throws IllegalArgumentException - if a Campaign object or campaign id is not passed
313:      * @return boolean 
314:      */
315:     public function deleteEmailCampaign($accessToken, $campaign)
316:     {
317:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
318:         return $this->emailMarketingService->deleteCampaign($accessToken, $campaignId);
319:     }
320:     
321:     /**
322:      * Create a new campaign
323:      * @param string $accessToken - Constant Contact OAuth2 access token
324:      * @param Campaign $campaign - Campaign to be created
325:      * @return Campaign - created campaign
326:      */
327:     public function addEmailCampaign($accessToken, Campaign $campaign)
328:     {
329:         return $this->emailMarketingService->addCampaign($accessToken, $campaign);
330:     }
331:     
332:     /**
333:      * Update a specific campaign
334:      * @param string $accessToken - Constant Contact OAuth2 access token
335:      * @param Campaign $campaign - Campaign to be updated
336:      * @return Campaign - updated campaign
337:      */
338:     public function updateEmailCampaign($accessToken, Campaign $campaign)
339:     {
340:         return $this->emailMarketingService->updateCampaign($accessToken, $campaign);
341:     }
342:     
343:     /**
344:      * Schedule a campaign to be sent
345:      * @param string $accessToken - Constant Contact OAuth2 access token
346:      * @param mixed $campaign - Campaign to be updated
347:      * @param Schedule $schedule - Schedule to be associated with the provided campaign
348:      * @return Schedule schedule created
349:      */
350:     public function addEmailCampaignSchedule($accessToken, $campaign, Schedule $schedule)
351:     {
352:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
353:         return $this->campaignScheduleService->addSchedule($accessToken, $campaignId, $schedule);
354:     }
355:     
356:     /**
357:      * Get an array of schedules associated with a given campaign
358:      * @param string $accessToken - Constant Contact OAuth2 access token
359:      * @param mixed $campaign - Campaign id  or Campaign object itself
360:      * @return array
361:      */
362:     public function getEmailCampaignSchedules($accessToken, $campaign)
363:     {
364:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
365:         return $this->campaignScheduleService->getSchedules($accessToken, $campaignId);
366:     }
367:     
368:     /**
369:      * Get a specific schedule associated with a given campaign
370:      * @param string $accessToken - Constant Contact OAuth2 access token
371:      * @param mixed $campaign - Campaign id or Campaign object itself
372:      * @param mixed $schedule - Schedule id or Schedule object itself
373:      * @throws IllegalArgumentException
374:      * @return array
375:      */
376:     public function getEmailCampaignSchedule($accessToken, $campaign, $schedule)
377:     {
378:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
379:         $scheduleId = null;
380: 
381:         if ($schedule instanceof Schedule) {
382:             $scheduleId = $schedule->id;
383:         } elseif (is_numeric($schedule)) {
384:             $scheduleId = $schedule;
385:         } else {
386:             throw new IllegalArgumentException(sprintf(Config::get('errors.id_or_object'), 'Schedule'));
387:         }
388:         
389:         return $this->campaignScheduleService->getSchedule($accessToken, $campaignId, $scheduleId);
390:     }
391:     
392:     /**
393:      * Update a specific schedule associated with a given campaign
394:      * @param string $accessToken - Constant Contact OAuth2 access token
395:      * @param mixed $campaign - Campaign id or Campaign object itself
396:      * @param Schedule $schedule - Schedule to be updated
397:      * @return array
398:      */
399:     public function updateEmailCampaignSchedule($accessToken, $campaign, Schedule $schedule)
400:     {
401:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
402:         return $this->campaignScheduleService->updateSchedule($accessToken, $campaignId, $schedule);
403:     }
404:     
405:     /**
406:      * Delete a specific schedule associated with a given campaign
407:      * @param string $accessToken - Constant Contact OAuth2 access token
408:      * @param mixed $campaign - Campaign id or Campaign object itself
409:      * @param mixed $schedule - Schedule id or Schedule object itself
410:      * @throws IllegalArgumentException
411:      * @return array
412:      */
413:     public function deleteEmailCampaignSchedule($accessToken, $campaign, $schedule)
414:     {
415:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
416:         $scheduleId = null;
417:         
418:         if ($schedule instanceof Schedule) {
419:             $scheduleId = $schedule->id;
420:         } elseif (is_numeric($schedule)) {
421:             $scheduleId = $schedule;
422:         } else {
423:             throw new IllegalArgumentException(sprintf(Config::get('errors.id_or_object'), 'Schedule'));
424:         }
425:         
426:         return $this->campaignScheduleService->deleteSchedule($accessToken, $campaignId, $scheduleId);
427:     }
428: 
429:     /**
430:      * Send a test send of a campaign
431:      * @param string $accessToken - Constant Contact OAuth2 access token
432:      * @param mixed $emailCampaign  - Campaign id or Campaign object itself
433:      * @param TestSend $test_send - test send details
434:      * @return TestSend
435:      */
436:     public function sendEmailCampaignTest($accessToken, $campaign, TestSend $test_send)
437:     {
438:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
439:         return $this->campaignScheduleService->sendTest($accessToken, $campaignId, $test_send);
440:     }
441: 
442:     /**
443:      * Get sends for a campaign
444:      * @param string $accessToken - Constant Contact OAuth2 access token
445:      * @param mixed $campaign - Campaign id or Campaign object itself
446:      * @param mixed $params - associative array of query parameters and values to append to the request. 
447:      *      Allow parameters include:
448:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
449:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
450:      *      next - the next link returned from a previous paginated call. May only be used by itself.
451:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\SendActivity}
452:      */
453:     public function getEmailCampaignSends($accessToken, $campaign, array $params = array())
454:     {
455:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
456:         return $this->campaignTrackingService->getSends($accessToken, $campaignId, $params);
457:     }
458: 
459:     /**
460:      * Get bounces for a campaign
461:      * @param string $accessToken - Constant Contact OAuth2 access token
462:      * @param mixed $campaign  - Campaign id or Campaign object itself
463:      * @param mixed $params - associative array of query parameters and values to append to the request. 
464:      *      Allow parameters include:
465:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
466:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
467:      *      next - the next link returned from a previous paginated call. May only be used by itself.
468:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\BounceActivity}
469:      */
470:     public function getEmailCampaignBounces($accessToken, $campaign, array $params = array())
471:     {
472:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
473:         return $this->campaignTrackingService->getBounces($accessToken, $campaignId, $params);
474:     }
475: 
476:     /**
477:      * Get clicks for a campaign
478:      * @param string $accessToken - Constant Contact OAuth2 access token
479:      * @param mixed $emailCampaign  - Campaign id or Campaign object itself
480:      * @param mixed $params - associative array of query parameters and values to append to the request. 
481:      *      Allow parameters include:
482:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
483:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
484:      *      next - the next link returned from a previous paginated call. May only be used by itself.
485:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\ClickActivity}
486:      */
487:     public function getEmailCampaignClicks($accessToken, $campaign, array $params = array())
488:     {
489:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
490:         return $this->campaignTrackingService->getClicks($accessToken, $campaignId, $params);
491:     }
492: 
493:     /**
494:      * Get opens for a campaign
495:      * @param string $accessToken - Constant Contact OAuth2 access token
496:      * @param mixed $campaign  - Campaign id or Campaign object itself
497:      * @param mixed $params - associative array of query parameters and values to append to the request. 
498:      *      Allow parameters include:
499:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
500:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
501:      *      next - the next link returned from a previous paginated call. May only be used by itself.
502:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\OpenActivity}
503:      */
504:     public function getEmailCampaignOpens($accessToken, $campaign, array $params = array())
505:     {
506:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
507:         return $this->campaignTrackingService->getOpens($accessToken, $campaignId, $params);
508:     }
509: 
510:     /**
511:      * Get forwards for a campaign
512:      * @param string $accessToken - Constant Contact OAuth2 access token
513:      * @param mixed $campaign  - Campaign id or Campaign object itself
514:      * @param mixed $params - associative array of query parameters and values to append to the request. 
515:      *      Allow parameters include:
516:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
517:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
518:      *      next - the next link returned from a previous paginated call. May only be used by itself.
519:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\ForwardActivity}
520:      */
521:     public function getEmailCampaignForwards($accessToken, $campaign, array $params = array())
522:     {
523:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
524:         return $this->campaignTrackingService->getForwards($accessToken, $campaignId, $params);
525:     }
526: 
527:     /**
528:      * Get unsubscribes for a campaign
529:      * @param string $accessToken - Constant Contact OAuth2 access token
530:      * @param mixed $campaign  - Campaign id or Campaign object itself
531:      * @param mixed $params - associative array of query parameters and values to append to the request. 
532:      *      Allow parameters include:
533:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
534:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
535:      *      next - the next link returned from a previous paginated call. May only be used by itself.
536:      * @return ResultSet - Containing a results array of {@link Ctct\Components\CampaignTracking\UnsubscribeActivity}
537:      */
538:     public function getEmailCampaignUnsubscribes($accessToken, $campaign, array $params = array())
539:     {
540:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
541:         return $this->campaignTrackingService->getUnsubscribes($accessToken, $campaignId, $params);
542:     }
543: 
544:     /**
545:      * Get a reporting summary for a campaign
546:      * @param string $accessToken - Constant Contact OAuth2 access token
547:      * @param mixed $campaign  - Campaign id or Campaign object itself
548:      * @return TrackingSummary
549:      */
550:     public function getEmailCampaignSummaryReport($accessToken, $campaign)
551:     {
552:         $campaignId = $this->getArgumentId($campaign, 'Campaign');
553:         return $this->campaignTrackingService->getSummary($accessToken, $campaignId);
554:     }
555: 
556:     /**
557:      * Get sends for a Contact
558:      * @param string $accessToken - Constant Contact OAuth2 access token
559:      * @param mixed $contact  - Contact id or Contact object itself
560:      * @param mixed $params - associative array of query parameters and values to append to the request. 
561:      *      Allow parameters include:
562:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
563:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
564:      *      next - the next link returned from a previous paginated call. May only be used by itself.
565:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\SendActivity}
566:      */
567:     public function getContactSends($accessToken, $contact, array $params = array())
568:     {
569:         $contactId = $this->getArgumentId($contact, 'Contact');
570:         return $this->contactTrackingService->getSends($accessToken, $contactId, $params);
571:     }
572: 
573:     /**
574:      * Get bounces for a Contact
575:      * @param string $accessToken - Constant Contact OAuth2 access token
576:      * @param mixed $contact  - Contact id or Contact object itself
577:      * @param mixed $params - associative array of query parameters and values to append to the request. 
578:      *      Allow parameters include:
579:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
580:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
581:      *      next - the next link returned from a previous paginated call. May only be used by itself.
582:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\BounceActivity}
583:      */
584:     public function getContactBounces($accessToken, $contact, array $params = array())
585:     {
586:         $contactId = $this->getArgumentId($contact, 'Contact');
587:         return $this->contactTrackingService->getBounces($accessToken, $contactId, $params);
588:     }
589: 
590:     /**
591:      * Get clicks for a Contact
592:      * @param string $accessToken - Constant Contact OAuth2 access token
593:      * @param mixed $contact  - Contact id or Contact object itself
594:      * @param mixed $params - associative array of query parameters and values to append to the request. 
595:      *      Allow parameters include:
596:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
597:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
598:      *      next - the next link returned from a previous paginated call. May only be used by itself.
599:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\ClickActivity}
600:      */
601:     public function getContactClicks($accessToken, $contact, array $params = array())
602:     {
603:         $contactId = $this->getArgumentId($contact, 'Contact');
604:         return $this->contactTrackingService->getClicks($accessToken, $contactId, $params);
605:     }
606: 
607:     /**
608:      * Get opens for a Contact
609:      * @param string $accessToken - Constant Contact OAuth2 access token
610:      * @param mixed $contact  - Contact id or Contact object itself
611:      * @param mixed $params - associative array of query parameters and values to append to the request. 
612:      *      Allow parameters include:
613:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
614:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
615:      *      next - the next link returned from a previous paginated call. May only be used by itself.
616:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\OpenActivity}
617:      */
618:     public function getContactOpens($accessToken, $contact, array $params = array())
619:     {
620:         $contactId = $this->getArgumentId($contact, 'Contact');
621:         return $this->contactTrackingService->getOpens($accessToken, $contactId, $params);
622:     }
623: 
624:     /**
625:      * Get forwards for a Contact
626:      * @param string $accessToken - Constant Contact OAuth2 access token
627:      * @param mixed $contact  - Contact id or Contact object itself
628:      * @param mixed $params - associative array of query parameters and values to append to the request. 
629:      *      Allow parameters include:
630:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
631:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
632:      *      next - the next link returned from a previous paginated call. May only be used by itself.
633:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\ForwardActivity}
634:      */
635:     public function getContactForwards($accessToken, $contact, array $params = array())
636:     {
637:         $contactId = $this->getArgumentId($contact, 'Contact');
638:         return $this->contactTrackingService->getForwards($accessToken, $contactId, $params);
639:     }
640: 
641:     /**
642:      * Get opt outs for a Contact
643:      * @param string $accessToken - Constant Contact OAuth2 access token
644:      * @param mixed $contact  - Contact id or Contact object itself
645:      * @param mixed $params - associative array of query parameters and values to append to the request. 
646:      *      Allow parameters include:
647:      *      limit - Specifies the number of results displayed per page of output, from 1 - 500, default = 50.
648:      *      created_since - Used to retrieve a list of events since the date and time specified (in ISO-8601 format).
649:      *      next - the next link returned from a previous paginated call. May only be used by itself.
650:      * @return ResultSet - Containing a results array of {@link Ctct\Components\Tracking\UnsubscribeActivity}
651:      */
652:     public function getContactUnsubscribes($accessToken, $contact, array $params = array())
653:     {
654:         $contactId = $this->getArgumentId($contact, 'Contact');
655:         return $this->contactTrackingService->getUnsubscribes($accessToken, $contactId, $params);
656:     }
657: 
658:     /**
659:      * Get verified addresses for the account
660:      * @param string $accessToken - Constant Contact OAuth2 access token
661:      * @param string $status - Status to filter query results by
662:      * @return array of VerifiedEmailAddress objects
663:      */
664:     public function getVerifiedEmailAddresses($accessToken, $status = null)
665:     {
666:         $params = array();
667:         if ($status) {
668:             $params['status'] = $status;
669:         }
670:         return $this->accountService->getVerifiedEmailAddresses($accessToken, $params);
671:     }
672: 
673:     /**
674:      * Get a reporting summary for a Contact
675:      * @param string $accessToken - Constant Contact OAuth2 access token
676:      * @param mixed $contact  - Contact id or Contact object itself
677:      * @return TrackingSummary
678:      */
679:     public function getContactSummaryReport($accessToken, $contact)
680:     {
681:         $contactId = $this->getArgumentId($contact, 'Contact');
682:         return $this->contactTrackingService->getSummary($accessToken, $contactId);
683:     }
684: 
685:     /**
686:      * Get an array of activities
687:      * @param string $accessToken - Constant Contact OAuth2 access token
688:      * @return array of {@link Ctct\Components\Activities\Activity}
689:      */
690:     public function getActivities($accessToken)
691:     {
692:         return $this->activityService->getActivities($accessToken);
693:     }
694: 
695:     /**
696:      * Get a single activity by id
697:      * @param string $accessToken - Constant Contact OAuth2 access token
698:      * @param string $activityId - Activity id
699:      * @return {@link Ctct\Components\Activities\Activity} 
700:      */
701:     public function getActivity($accessToken, $activityId)
702:     {
703:         return $this->activityService->getActivity($accessToken, $activityId);
704:     }
705: 
706:     /**
707:      * Add an AddContacts Activity to add contacts in bulk
708:      * @param string $accessToken - Constant Contact OAuth2 access token
709:      * @param AddContacts - Add Contacts Activity
710:      */
711:     public function addCreateContactsActivity($accessToken, AddContacts $addContactsActivity)
712:     {
713:         return $this->activityService->createAddContactsActivity($accessToken, $addContactsActivity);
714:     }
715: 
716:     /**
717:      * Add an ClearLists Activity to remove all contacts from the provided lists
718:      * @param string $accessToken - Constant Contact OAuth2 access token
719:      * @param AddContacts - Add Contacts Activity
720:      */
721:     public function addClearListsActivity($accessToken, Array $lists)
722:     {
723:         return $this->activityService->addClearListsActivity($accessToken, $lists);
724:     }
725: 
726:     /**
727:      * Add a Remove Contacts From Lists Activity
728:      * @param string $accessToken - Constant Contact OAuth2 access token
729:      * @param array $emailAddresses - email addresses to be removed
730:      * @param array $lists - lists to remove the provided email addresses from
731:      * @param AddContacts - Add Contacts Activity
732:      */
733:     public function addRemoveContactsFromListsActivity($accessToken, Array $emailAddresses, Array $lists)
734:     {
735:         return $this->activityService->addRemoveContactsFromListsActivity($accessToken, $emailAddresses, $lists);
736:     }
737: 
738:      /**
739:      * Create an Export Contacts Activity
740:      * @param string $accessToken - Constant Contact OAuth2 access token
741:      * @param ExportContacts $exportContacts
742:      * @return array - Array of all ActivitySummaryReports
743:      */
744:     public function addExportContactsActivity($accessToken, ExportContacts $exportContacts)
745:     {
746:         return $this->activityService->addExportContactsActivity($accessToken, $exportContacts);
747:     }
748:     
749:     /**
750:      * Get the id of object, or attempt to convert the argument to an int
751:      * @param mixed $item - object or a numeric value
752:      * @param string $class_name - class name to test the given object against
753:      * @throws IllegalArgumentException - if the item is not an instance of the class name given, or cannot be
754:      * converted to a numeric value
755:      * @return int
756:      */
757:     private function getArgumentId($item, $className)
758:     {
759:         $id = null;
760: 
761:         if (is_numeric($item)) {
762:             $id = $item;
763:         } elseif (join('', array_slice(explode('\\', get_class($item)), -1)) == $className) {
764:             $id = $item->id;
765:         } else {
766:             throw new IllegalArgumentException(sprintf(Config::get('errors.id_or_object'), $className));
767:         }
768: 
769:         return $id;
770:     }
771: 
772:     /**
773:      * Builds an array of query parameters to be added to the request
774:      * @param string $param
775:      * @return array
776:      */
777:     private function determineParam($param)
778:     {
779:         $params = array();
780:         if (substr($param, 0, 1) === '?') {
781:             $param = substr($param, 1);
782:             parse_str($param, $params);
783:         } else {
784:             $params['limit'] = $param;
785:         }
786:         return $params;
787:     }
788: }
789: 
Appconnect PHP SDK API documentation generated by ApiGen 2.8.0