Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like CampaignMonitorAPIConnector often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use CampaignMonitorAPIConnector, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
7 | class CampaignMonitorAPIConnector extends Object |
||
|
|||
8 | { |
||
9 | |||
10 | /** |
||
11 | * REQUIRED! |
||
12 | * this is the CM url for logging in. |
||
13 | * which can be used by the client. |
||
14 | * @var String |
||
15 | */ |
||
16 | private static $campaign_monitor_url = ""; |
||
17 | |||
18 | /** |
||
19 | * REQUIRED! |
||
20 | * @var String |
||
21 | */ |
||
22 | private static $client_id = ""; |
||
23 | |||
24 | |||
25 | /** |
||
26 | * OPTION 1: API KEY! |
||
27 | * @var String |
||
28 | */ |
||
29 | private static $api_key = ""; |
||
30 | |||
31 | |||
32 | /** |
||
33 | * OPTION 2: OAUTH OPTION |
||
34 | * @var String |
||
35 | */ |
||
36 | private static $client_secret = ""; |
||
37 | |||
38 | /** |
||
39 | * OPTION 2: OAUTH OPTION |
||
40 | * @var String |
||
41 | */ |
||
42 | private static $redirect_uri = ""; |
||
43 | |||
44 | /** |
||
45 | * OPTION 2: OAUTH OPTION |
||
46 | * @var String |
||
47 | */ |
||
48 | private static $code = ""; |
||
49 | |||
50 | /** |
||
51 | * |
||
52 | * @var Boolean |
||
53 | */ |
||
54 | protected $debug = false; |
||
55 | |||
56 | /** |
||
57 | * |
||
58 | * @var Boolean |
||
59 | */ |
||
60 | protected $allowCaching = false; |
||
61 | |||
62 | /** |
||
63 | * |
||
64 | * @var Int |
||
65 | */ |
||
66 | protected $httpStatusCode = 0; |
||
67 | |||
68 | |||
69 | /** |
||
70 | * |
||
71 | * must be called to use this API. |
||
72 | */ |
||
73 | public function init() |
||
78 | |||
79 | /** |
||
80 | * turn debug on or off |
||
81 | * |
||
82 | * @param Boolean |
||
83 | */ |
||
84 | public function setDebug($b) |
||
88 | |||
89 | /** |
||
90 | * |
||
91 | * @param Boolean $b |
||
92 | */ |
||
93 | public function setAllowCaching($b) |
||
97 | |||
98 | /** |
||
99 | * |
||
100 | * @return Boolean |
||
101 | */ |
||
102 | public function getAllowCaching() |
||
106 | |||
107 | /** |
||
108 | * provides the Authorisation Array |
||
109 | * @return Array |
||
110 | */ |
||
111 | protected function getAuth() |
||
159 | |||
160 | /** |
||
161 | * returns the result or NULL in case of an error |
||
162 | * @param CS_REST_Wrapper_Result |
||
163 | * @return Mixed | Null |
||
164 | */ |
||
165 | protected function returnResult($result, $apiCall, $description) |
||
191 | |||
192 | /** |
||
193 | * returns the HTTP code for the response. |
||
194 | * This can be handy for debuging purposes. |
||
195 | * @return Int |
||
196 | */ |
||
197 | public function getHttpStatusCode() |
||
201 | |||
202 | /******************************************************* |
||
203 | * caching |
||
204 | * |
||
205 | *******************************************************/ |
||
206 | |||
207 | /** |
||
208 | * @param String $name |
||
209 | * @return Mixed |
||
210 | */ |
||
211 | View Code Duplication | protected function getFromCache($name) |
|
223 | |||
224 | /** |
||
225 | * @param Mixed $unserializedValue |
||
226 | * @param String $name |
||
227 | */ |
||
228 | View Code Duplication | protected function saveToCache($unserializedValue, $name) |
|
238 | |||
239 | |||
240 | /******************************************************* |
||
241 | * client |
||
242 | * |
||
243 | *******************************************************/ |
||
244 | |||
245 | /** |
||
246 | * |
||
247 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
248 | * array( |
||
249 | * { |
||
250 | * 'WebVersionURL' => The web version url of the campaign |
||
251 | * 'WebVersionTextURL' => The web version url of the text version of the campaign |
||
252 | * 'CampaignID' => The id of the campaign |
||
253 | * 'Subject' => The campaign subject |
||
254 | * 'Name' => The name of the campaign |
||
255 | * 'FromName' => The from name for the campaign |
||
256 | * 'FromEmail' => The from email address for the campaign |
||
257 | * 'ReplyTo' => The reply to email address for the campaign |
||
258 | * 'SentDate' => The sent data of the campaign |
||
259 | * 'TotalRecipients' => The number of recipients of the campaign |
||
260 | * } |
||
261 | */ |
||
262 | View Code Duplication | public function getCampaigns() |
|
273 | |||
274 | View Code Duplication | public function getDrafts() |
|
285 | |||
286 | /** |
||
287 | * Gets all subscriber lists the current client has created |
||
288 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
289 | * array( |
||
290 | * { |
||
291 | * 'ListID' => The id of the list |
||
292 | * 'Name' => The name of the list |
||
293 | * } |
||
294 | * ) |
||
295 | */ |
||
296 | View Code Duplication | public function getLists() |
|
307 | |||
308 | public function getScheduled() |
||
312 | |||
313 | /** |
||
314 | * list of people that are definitely suppressed... |
||
315 | * @param int $page page number |
||
316 | * @param int $pageSize size of page |
||
317 | * @param string $sortByField (email) |
||
318 | * @param string $sortDirection (asc) |
||
319 | * |
||
320 | * @return [type] [description] |
||
321 | */ |
||
322 | public function getSuppressionlist($page, $pageSize, $sortByField = 'email', $sortDirection = 'asc') |
||
341 | |||
342 | View Code Duplication | public function getTemplates() |
|
355 | |||
356 | View Code Duplication | public function getTemplate($templatID) |
|
369 | |||
370 | /** |
||
371 | * |
||
372 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
373 | * |
||
374 | * @return CS_REST_Wrapper_Result |
||
375 | */ |
||
376 | View Code Duplication | public function createTemplate($campaignMonitorCampaign) |
|
415 | |||
416 | /** |
||
417 | * |
||
418 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
419 | * @param string $templateID |
||
420 | * |
||
421 | * @return CS_REST_Wrapper_Result |
||
422 | */ |
||
423 | View Code Duplication | public function updateTemplate($campaignMonitorCampaign, $templateID) |
|
460 | |||
461 | View Code Duplication | public function deleteTemplate($templateID) |
|
471 | |||
472 | /******************************************************* |
||
473 | * lists |
||
474 | * |
||
475 | *******************************************************/ |
||
476 | |||
477 | /** |
||
478 | * Creates a new list based on the provided details. |
||
479 | * Both the UnsubscribePage and the ConfirmationSuccessPage parameters are optional |
||
480 | * |
||
481 | * @param string $title - the page to redirect subscribers to when they unsubscribeThe list title |
||
482 | * @param string $unsubscribePage - The page to redirect subscribers to when they unsubscribe |
||
483 | * @param boolean $confirmedOptIn - Whether this list requires confirmation of subscription |
||
484 | * @param string $confirmationSuccessPage - The page to redirect subscribers to when they confirm their subscription |
||
485 | * @param string $unsubscribeSetting - Unsubscribe setting must be CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS or CS_REST_LIST_UNSUBSCRIBE_SETTING_ONLY_THIS_LIST. See the documentation for details: http://www.campaignmonitor.com/api/lists/#creating_a_list |
||
486 | * |
||
487 | * @return CS_REST_Wrapper_Result A successful response will be the ID of the newly created list |
||
488 | */ |
||
489 | public function createList($title, $unsubscribePage, $confirmedOptIn = false, $confirmationSuccessPage, $unsubscribeSetting = null) |
||
514 | |||
515 | /** |
||
516 | * Creates custom field for list |
||
517 | * |
||
518 | * @param string $listID - list ID |
||
519 | * @param string $type - type of custom field |
||
520 | * @param string $title - field type |
||
521 | * @param array $options - options for dropdown field type |
||
522 | * |
||
523 | * @return CS_REST_Wrapper_Result A successful response will be the key of the newly created custom field |
||
524 | */ |
||
525 | public function createCustomField($listID, $visible, $type, $title, $options = array()) |
||
559 | |||
560 | /** |
||
561 | * Creates custom field for list |
||
562 | * |
||
563 | * @param string $listID - list ID |
||
564 | * @param string $key |
||
565 | * |
||
566 | * @return CS_REST_Wrapper_Result |
||
567 | */ |
||
568 | View Code Duplication | public function deleteCustomField($listID, $key) |
|
578 | |||
579 | /** |
||
580 | * Deletes an existing list from the system |
||
581 | * @param Int $listID |
||
582 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
583 | */ |
||
584 | View Code Duplication | public function deleteList($listID) |
|
595 | |||
596 | /** |
||
597 | * Gets the basic details of the current list |
||
598 | * |
||
599 | * @param Int $listID |
||
600 | * |
||
601 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
602 | * { |
||
603 | * 'ListID' => The id of the list |
||
604 | * 'Title' => The title of the list |
||
605 | * 'UnsubscribePage' => The page which subscribers are redirected to upon unsubscribing |
||
606 | * 'ConfirmedOptIn' => Whether the list is Double-Opt In |
||
607 | * 'ConfirmationSuccessPage' => The page which subscribers are |
||
608 | * redirected to upon confirming their subscription |
||
609 | * 'UnsubscribeSetting' => The unsubscribe setting for the list. Will |
||
610 | * be either CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS or |
||
611 | * CS_REST_LIST_UNSUBSCRIBE_SETTING_ONLY_THIS_LIST. |
||
612 | * } |
||
613 | */ |
||
614 | View Code Duplication | public function getList($listID) |
|
625 | |||
626 | /** |
||
627 | * Gets all active subscribers added since the given date |
||
628 | * |
||
629 | * @param Int $listID |
||
630 | * @param string $daysAgo The date to start getting subscribers from |
||
631 | * @param int $page The page number to get |
||
632 | * @param int $pageSize The number of records per page |
||
633 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
634 | * @param string $sortDirection ('ASC', 'DESC') |
||
635 | * |
||
636 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
637 | * { |
||
638 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
639 | * 'OrderDirection' => The order direction |
||
640 | * 'PageNumber' => The page number for the result set |
||
641 | * 'PageSize' => The page size used |
||
642 | * 'RecordsOnThisPage' => The number of records returned |
||
643 | * 'TotalNumberOfRecords' => The total number of records available |
||
644 | * 'NumberOfPages' => The total number of pages for this collection |
||
645 | * 'Results' => array( |
||
646 | * { |
||
647 | * 'EmailAddress' => The email address of the subscriber |
||
648 | * 'Name' => The name of the subscriber |
||
649 | * 'Date' => The date that the subscriber was added to the list |
||
650 | * 'State' => The current state of the subscriber, will be 'Active' |
||
651 | * 'CustomFields' => array ( |
||
652 | * { |
||
653 | * 'Key' => The personalisation tag of the custom field |
||
654 | * 'Value' => The value of the custom field for this subscriber |
||
655 | * } |
||
656 | * ) |
||
657 | * } |
||
658 | * ) |
||
659 | * } |
||
660 | */ |
||
661 | View Code Duplication | public function getActiveSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
678 | |||
679 | /** |
||
680 | * Gets all unconfirmed subscribers added since the given date |
||
681 | * |
||
682 | * @param Int $listID |
||
683 | * @param string $daysAgo The date to start getting subscribers from |
||
684 | * @param int $page The page number to get |
||
685 | * @param int $pageSize The number of records per page |
||
686 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
687 | * @param string $sortDirection ('ASC', 'DESC') |
||
688 | * |
||
689 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
690 | * { |
||
691 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
692 | * 'OrderDirection' => The order direction |
||
693 | * 'PageNumber' => The page number for the result set |
||
694 | * 'PageSize' => The page size used |
||
695 | * 'RecordsOnThisPage' => The number of records returned |
||
696 | * 'TotalNumberOfRecords' => The total number of records available |
||
697 | * 'NumberOfPages' => The total number of pages for this collection |
||
698 | * 'Results' => array( |
||
699 | * { |
||
700 | * 'EmailAddress' => The email address of the subscriber |
||
701 | * 'Name' => The name of the subscriber |
||
702 | * 'Date' => The date that the subscriber was added to the list |
||
703 | * 'State' => The current state of the subscriber, will be 'Unconfirmed' |
||
704 | * 'CustomFields' => array ( |
||
705 | * { |
||
706 | * 'Key' => The personalisation tag of the custom field |
||
707 | * 'Value' => The value of the custom field for this subscriber |
||
708 | * } |
||
709 | * ) |
||
710 | * } |
||
711 | * ) |
||
712 | * } |
||
713 | */ |
||
714 | View Code Duplication | public function getUnconfirmedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
731 | |||
732 | /** |
||
733 | * Gets all bounced subscribers who have bounced out since the given date |
||
734 | * |
||
735 | * @param Int $listID |
||
736 | * @param string $daysAgo The date to start getting subscribers from |
||
737 | * @param int $page The page number to get |
||
738 | * @param int $pageSize The number of records per page |
||
739 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
740 | * @param string $sortDirection ('ASC', 'DESC') |
||
741 | * |
||
742 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
743 | * { |
||
744 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
745 | * 'OrderDirection' => The order direction |
||
746 | * 'PageNumber' => The page number for the result set |
||
747 | * 'PageSize' => The page size used |
||
748 | * 'RecordsOnThisPage' => The number of records returned |
||
749 | * 'TotalNumberOfRecords' => The total number of records available |
||
750 | * 'NumberOfPages' => The total number of pages for this collection |
||
751 | * 'Results' => array( |
||
752 | * { |
||
753 | * 'EmailAddress' => The email address of the subscriber |
||
754 | * 'Name' => The name of the subscriber |
||
755 | * 'Date' => The date that the subscriber bounced out of the list |
||
756 | * 'State' => The current state of the subscriber, will be 'Bounced' |
||
757 | * 'CustomFields' => array ( |
||
758 | * { |
||
759 | * 'Key' => The personalisation tag of the custom field |
||
760 | * 'Value' => The value of the custom field for this subscriber |
||
761 | * } |
||
762 | * ) |
||
763 | * } |
||
764 | * ) |
||
765 | * } |
||
766 | */ |
||
767 | View Code Duplication | public function getBouncedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
784 | |||
785 | |||
786 | /** |
||
787 | * Gets all unsubscribed subscribers who have unsubscribed since the given date |
||
788 | * |
||
789 | * @param Int $listID |
||
790 | * @param string $daysAgo The date to start getting subscribers from |
||
791 | * @param int $page The page number to get |
||
792 | * @param int $pageSize The number of records per page |
||
793 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
794 | * @param string $sortDirection ('ASC', 'DESC') |
||
795 | * |
||
796 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
797 | * { |
||
798 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
799 | * 'OrderDirection' => The order direction |
||
800 | * 'PageNumber' => The page number for the result set |
||
801 | * 'PageSize' => The page size used |
||
802 | * 'RecordsOnThisPage' => The number of records returned |
||
803 | * 'TotalNumberOfRecords' => The total number of records available |
||
804 | * 'NumberOfPages' => The total number of pages for this collection |
||
805 | * 'Results' => array( |
||
806 | * { |
||
807 | * 'EmailAddress' => The email address of the subscriber |
||
808 | * 'Name' => The name of the subscriber |
||
809 | * 'Date' => The date that the subscriber was unsubscribed from the list |
||
810 | * 'State' => The current state of the subscriber, will be 'Unsubscribed' |
||
811 | * 'CustomFields' => array ( |
||
812 | * { |
||
813 | * 'Key' => The personalisation tag of the custom field |
||
814 | * 'Value' => The value of the custom field for this subscriber |
||
815 | * } |
||
816 | * ) |
||
817 | * } |
||
818 | * ) |
||
819 | * } |
||
820 | */ |
||
821 | View Code Duplication | public function getUnsubscribedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
838 | |||
839 | /** |
||
840 | * Gets all unsubscribed subscribers who have unsubscribed since the given date |
||
841 | * |
||
842 | * @param Int $listID |
||
843 | * @param string $daysAgo The date to start getting subscribers from |
||
844 | * @param int $page The page number to get |
||
845 | * @param int $pageSize The number of records per page |
||
846 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
847 | * @param string $sortDirection ('ASC', 'DESC') |
||
848 | * |
||
849 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
850 | * { |
||
851 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
852 | * 'OrderDirection' => The order direction |
||
853 | * 'PageNumber' => The page number for the result set |
||
854 | * 'PageSize' => The page size used |
||
855 | * 'RecordsOnThisPage' => The number of records returned |
||
856 | * 'TotalNumberOfRecords' => The total number of records available |
||
857 | * 'NumberOfPages' => The total number of pages for this collection |
||
858 | * 'Results' => array( |
||
859 | * { |
||
860 | * 'EmailAddress' => The email address of the subscriber |
||
861 | * 'Name' => The name of the subscriber |
||
862 | * 'Date' => The date that the subscriber was unsubscribed from the list |
||
863 | * 'State' => The current state of the subscriber, will be 'Unsubscribed' |
||
864 | * 'CustomFields' => array ( |
||
865 | * { |
||
866 | * 'Key' => The personalisation tag of the custom field |
||
867 | * 'Value' => The value of the custom field for this subscriber |
||
868 | * } |
||
869 | * ) |
||
870 | * } |
||
871 | * ) |
||
872 | * } |
||
873 | */ |
||
874 | public function getDeletedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "email", $sortDirection = "asc") |
||
891 | |||
892 | /** |
||
893 | * Updates the details of an existing list |
||
894 | * Both the UnsubscribePage and the ConfirmationSuccessPage parameters are optional |
||
895 | * |
||
896 | * @param string $title - he page to redirect subscribers to when they unsubscribeThe list title |
||
897 | * @param string $unsubscribePage - The page to redirect subscribers to when they unsubscribe |
||
898 | * @param boolean $confirmedOptIn - Whether this list requires confirmation of subscription |
||
899 | * @param string $confirmationSuccessPage - The page to redirect subscribers to when they confirm their subscription |
||
900 | * @param string $unsubscribeSetting - Unsubscribe setting must be CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS or CS_REST_LIST_UNSUBSCRIBE_SETTING_ONLY_THIS_LIST. See the documentation for details: http://www.campaignmonitor.com/api/lists/#creating_a_list |
||
901 | * @param boolean $addUnsubscribesToSuppList - When UnsubscribeSetting is CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS, whether unsubscribes from this list should be added to the suppression list. |
||
902 | * @param boolean $acrubActiveWithSuppList - When UnsubscribeSetting is CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS, whether active subscribers should be scrubbed against the suppression list. |
||
903 | * |
||
904 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
905 | */ |
||
906 | public function updateList($listID, $title, $unsubscribePage, $confirmedOptIn = false, $confirmationSuccessPage, $unsubscribeSetting, $addUnsubscribesToSuppList = true, $scrubActiveWithSuppList = true) |
||
928 | |||
929 | View Code Duplication | public function getSegments($listID) |
|
942 | |||
943 | /** |
||
944 | * Gets statistics for list subscriptions, deletions, bounces and unsubscriptions |
||
945 | * |
||
946 | * @param Int $listID |
||
947 | * |
||
948 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
949 | * { |
||
950 | * 'TotalActiveSubscribers' |
||
951 | * 'NewActiveSubscribersToday' |
||
952 | * 'NewActiveSubscribersYesterday' |
||
953 | * 'NewActiveSubscribersThisWeek' |
||
954 | * 'NewActiveSubscribersThisMonth' |
||
955 | * 'NewActiveSubscribersThisYeay' |
||
956 | * 'TotalUnsubscribes' |
||
957 | * 'UnsubscribesToday' |
||
958 | * 'UnsubscribesYesterday' |
||
959 | * 'UnsubscribesThisWeek' |
||
960 | * 'UnsubscribesThisMonth' |
||
961 | * 'UnsubscribesThisYear' |
||
962 | * 'TotalDeleted' |
||
963 | * 'DeletedToday' |
||
964 | * 'DeletedYesterday' |
||
965 | * 'DeletedThisWeek' |
||
966 | * 'DeletedThisMonth' |
||
967 | * 'DeletedThisYear' |
||
968 | * 'TotalBounces' |
||
969 | * 'BouncesToday' |
||
970 | * 'BouncesYesterday' |
||
971 | * 'BouncesThisWeek' |
||
972 | * 'BouncesThisMonth' |
||
973 | * 'BouncesThisYear' |
||
974 | * } |
||
975 | */ |
||
976 | View Code Duplication | public function getListStats($listID) |
|
987 | |||
988 | View Code Duplication | public function getListCustomFields($listID) |
|
998 | |||
999 | /******************************************************* |
||
1000 | * create campaigns |
||
1001 | * |
||
1002 | *******************************************************/ |
||
1003 | |||
1004 | /** |
||
1005 | * |
||
1006 | * |
||
1007 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
1008 | * @param array listIDs |
||
1009 | * @param array segmentIDs |
||
1010 | * @param string templateID - OPTIONAL! |
||
1011 | * @param array templateContent - OPTIONAL! |
||
1012 | */ |
||
1013 | public function createCampaign( |
||
1102 | |||
1103 | View Code Duplication | public function deleteCampaign($campaignID) |
|
1113 | |||
1114 | /******************************************************* |
||
1115 | * information about the campaigns |
||
1116 | * |
||
1117 | *******************************************************/ |
||
1118 | |||
1119 | public function getBounces() |
||
1123 | |||
1124 | public function getClicks() |
||
1128 | |||
1129 | /** |
||
1130 | * Gets a summary of all campaign reporting statistics |
||
1131 | * |
||
1132 | * @param int $campaignID |
||
1133 | * |
||
1134 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1135 | * { |
||
1136 | * 'Recipients' => The total recipients of the campaign |
||
1137 | * 'TotalOpened' => The total number of opens recorded |
||
1138 | * 'Clicks' => The total number of recorded clicks |
||
1139 | * 'Unsubscribed' => The number of recipients who unsubscribed |
||
1140 | * 'Bounced' => The number of recipients who bounced |
||
1141 | * 'UniqueOpened' => The number of recipients who opened |
||
1142 | * 'WebVersionURL' => The url of the web version of the campaign |
||
1143 | * 'WebVersionTextURL' => The url of the web version of the text version of the campaign |
||
1144 | * 'WorldviewURL' => The public Worldview URL for the campaign |
||
1145 | * 'Forwards' => The number of times the campaign has been forwarded to a friend |
||
1146 | * 'Likes' => The number of times the campaign has been 'liked' on Facebook |
||
1147 | * 'Mentions' => The number of times the campaign has been tweeted about |
||
1148 | * 'SpamComplaints' => The number of recipients who marked the campaign as spam |
||
1149 | * } |
||
1150 | */ |
||
1151 | View Code Duplication | public function getSummary($campaignID) |
|
1161 | |||
1162 | /** |
||
1163 | * Gets the email clients that subscribers used to open the campaign |
||
1164 | * |
||
1165 | * @param Int $campaignID |
||
1166 | * |
||
1167 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1168 | * array( |
||
1169 | * { |
||
1170 | * Client => The email client name |
||
1171 | * Version => The email client version |
||
1172 | * Percentage => The percentage of subscribers who used this email client |
||
1173 | * Subscribers => The actual number of subscribers who used this email client |
||
1174 | * } |
||
1175 | * ) |
||
1176 | */ |
||
1177 | View Code Duplication | public function getEmailClientUsage($campaignID) |
|
1187 | |||
1188 | public function getListsAndSegments() |
||
1192 | |||
1193 | public function getOpens() |
||
1197 | |||
1198 | public function getRecipients() |
||
1202 | |||
1203 | public function getSpam() |
||
1207 | |||
1208 | /** |
||
1209 | * Gets all unsubscribes recorded for a campaign since the provided date |
||
1210 | * |
||
1211 | * @param int $campaignID ID of the Campaign |
||
1212 | * @param string $daysAgo The date to start getting subscribers from |
||
1213 | * @param int $page The page number to get |
||
1214 | * @param int $pageSize The number of records per page |
||
1215 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
1216 | * @param string $sortDirection ('ASC', 'DESC') |
||
1217 | * |
||
1218 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1219 | * { |
||
1220 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
1221 | * 'OrderDirection' => The order direction |
||
1222 | * 'PageNumber' => The page number for the result set |
||
1223 | * 'PageSize' => The page size used |
||
1224 | * 'RecordsOnThisPage' => The number of records returned |
||
1225 | * 'TotalNumberOfRecords' => The total number of records available |
||
1226 | * 'NumberOfPages' => The total number of pages for this collection |
||
1227 | * 'Results' => array( |
||
1228 | * { |
||
1229 | * 'EmailAddress' => The email address of the subscriber who unsubscribed |
||
1230 | * 'ListID' => The list id of the list containing the subscriber |
||
1231 | * 'Date' => The date of the unsubscribe |
||
1232 | * 'IPAddress' => The ip address where the unsubscribe originated |
||
1233 | * } |
||
1234 | * ) |
||
1235 | * } |
||
1236 | */ |
||
1237 | View Code Duplication | public function getUnsubscribes($campaignID, $daysAgo = 3650, $page =1, $pageSize = 999, $sortByField = "EMAIL", $sortDirection = "ASC") |
|
1254 | |||
1255 | |||
1256 | |||
1257 | /******************************************************* |
||
1258 | * user |
||
1259 | * |
||
1260 | * states: |
||
1261 | * |
||
1262 | * Active – Someone who is on a list and will receive any emails sent to that list. |
||
1263 | * |
||
1264 | * Unconfirmed – The individual signed up to a confirmed opt-in list |
||
1265 | * but has not clicked the link in the verification email sent to them. |
||
1266 | * |
||
1267 | * Unsubscribed – The subscriber has removed themselves from a list, or lists, |
||
1268 | * via an unsubscribe link or form. |
||
1269 | * You can also change a subscriber's status to unsubscribed through your account. |
||
1270 | * |
||
1271 | * Bounced – This describes an email address that campaigns cannot be delivered to, |
||
1272 | * which can happen for a number of reasons. |
||
1273 | * |
||
1274 | * Deleted – Means the subscriber has been deleted from a list through your account. |
||
1275 | * |
||
1276 | *******************************************************/ |
||
1277 | |||
1278 | /** |
||
1279 | * Gets the lists across a client to which a subscriber with a particular |
||
1280 | * email address belongs. |
||
1281 | * |
||
1282 | * @param string | Member $email Subscriber's email address (or Member) |
||
1283 | * |
||
1284 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1285 | * array( |
||
1286 | * { |
||
1287 | * 'ListID' => The id of the list |
||
1288 | * 'ListName' => The name of the list |
||
1289 | * 'SubscriberState' => The state of the subscriber in the list |
||
1290 | * 'DateSubscriberAdded' => The date the subscriber was added |
||
1291 | * } |
||
1292 | * ) |
||
1293 | */ |
||
1294 | public function getListsForEmail($member) |
||
1308 | |||
1309 | |||
1310 | /** |
||
1311 | * Adds a new subscriber to the specified list |
||
1312 | * |
||
1313 | * @param Int $listID |
||
1314 | * @param Member $member |
||
1315 | * @param Array $customFields |
||
1316 | * @param array $customFields The subscriber details to use during creation. |
||
1317 | * @param boolean $resubscribe Whether we should resubscribe this subscriber if they already exist in the list |
||
1318 | * @param boolean $RestartSubscriptionBasedAutoResponders Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. |
||
1319 | * |
||
1320 | * NOTE that for the custom fields they need to be formatted like this: |
||
1321 | * Array( |
||
1322 | * 'Key' => The custom fields personalisation tag |
||
1323 | * 'Value' => The value for this subscriber |
||
1324 | * 'Clear' => true/false (pass true to remove this custom field. in the case of a [multi-option, select many] field, pass an option in the 'Value' field to clear that option or leave Value blank to remove all options) |
||
1325 | * ) |
||
1326 | * |
||
1327 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
1328 | */ |
||
1329 | public function addSubscriber( |
||
1363 | |||
1364 | /** |
||
1365 | * Updates an existing subscriber (email, name, state, or custom fields) in the specified list. |
||
1366 | * The update is performed even for inactive subscribers, but will return an error in the event of the |
||
1367 | * given email not existing in the list. |
||
1368 | * |
||
1369 | * @param Int $listID |
||
1370 | * @param String $oldEmailAddress |
||
1371 | * @param Member $member |
||
1372 | * @param array $customFields The subscriber details to use during creation. |
||
1373 | * @param boolean $resubscribe Whether we should resubscribe this subscriber if they already exist in the list |
||
1374 | * @param boolean $restartSubscriptionBasedAutoResponders Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. |
||
1375 | * |
||
1376 | * NOTE that for the custom fields they need to be formatted like this: |
||
1377 | * Array( |
||
1378 | * 'Key' => The custom fields personalisation tag |
||
1379 | * 'Value' => The value for this subscriber |
||
1380 | * 'Clear' => true/false (pass true to remove this custom field. in the case of a [multi-option, select many] field, pass an option in the 'Value' field to clear that option or leave Value blank to remove all options) |
||
1381 | * ) |
||
1382 | * |
||
1383 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
1384 | */ |
||
1385 | public function updateSubscriber( |
||
1424 | |||
1425 | /** |
||
1426 | * Updates an existing subscriber (email, name, state, or custom fields) in the specified list. |
||
1427 | * The update is performed even for inactive subscribers, but will return an error in the event of the |
||
1428 | * given email not existing in the list. |
||
1429 | * |
||
1430 | * @param Int $listID |
||
1431 | * @param ArraySet $memberSet - list of mebers |
||
1432 | * @param array $customFields The subscriber details to use during creation. Each array item needs to have the same key as the member ID - e.g. array( 123 => array( [custom fields here] ), 456 => array( [custom fields here] ) ) |
||
1433 | * @param $resubscribe Whether we should resubscribe any existing subscribers |
||
1434 | * @param $queueSubscriptionBasedAutoResponders By default, subscription based auto responders do not trigger during an import. Pass a value of true to override this behaviour |
||
1435 | * @param $restartSubscriptionBasedAutoResponders By default, subscription based auto responders will not be restarted |
||
1436 | * |
||
1437 | * NOTE that for the custom fields they need to be formatted like this: |
||
1438 | * Array( |
||
1439 | * 'Key' => The custom fields personalisation tag |
||
1440 | * 'Value' => The value for this subscriber |
||
1441 | * 'Clear' => true/false (pass true to remove this custom field. in the case of a [multi-option, select many] field, pass an option in the 'Value' field to clear that option or leave Value blank to remove all options) |
||
1442 | * ) |
||
1443 | |||
1444 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
1445 | */ |
||
1446 | public function addSubscribers( |
||
1494 | |||
1495 | /** |
||
1496 | * @param Int $listID |
||
1497 | * @param Member | String $member - email address or Member Object |
||
1498 | * |
||
1499 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
1500 | */ |
||
1501 | View Code Duplication | public function deleteSubscriber($listID, $member) |
|
1514 | |||
1515 | /** |
||
1516 | * Unsubscribes the given subscriber from the current list |
||
1517 | * |
||
1518 | * @param Int $listID |
||
1519 | * @param Member | String $member |
||
1520 | * |
||
1521 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
1522 | */ |
||
1523 | View Code Duplication | public function unsubscribeSubscriber($listID, $member) |
|
1536 | |||
1537 | /** |
||
1538 | * Is this user part of this list at all? |
||
1539 | * |
||
1540 | * @param Int $listID |
||
1541 | * @param Member | String $member |
||
1542 | * |
||
1543 | * @return Boolean |
||
1544 | */ |
||
1545 | View Code Duplication | public function getSubscriberExistsForThisList($listID, $member) |
|
1562 | |||
1563 | /** |
||
1564 | * Can we send e-mails to this person in the future for this list? |
||
1565 | * |
||
1566 | * @param Int $listID |
||
1567 | * @param Member | String $member |
||
1568 | * |
||
1569 | * @return Boolean |
||
1570 | */ |
||
1571 | View Code Duplication | public function getSubscriberCanReceiveEmailsForThisList($listID, $member) |
|
1590 | |||
1591 | /** |
||
1592 | * This e-mail / user has been banned from a list. |
||
1593 | * |
||
1594 | * @param Int $listID |
||
1595 | * @param Member | String $member |
||
1596 | * |
||
1597 | * @return Boolean |
||
1598 | */ |
||
1599 | public function getSubscriberCanNoLongerReceiveEmailsForThisList($listID, $member) |
||
1616 | |||
1617 | private static $_get_subscriber = array(); |
||
1618 | |||
1619 | /** |
||
1620 | * Gets a subscriber details, including custom fields |
||
1621 | * |
||
1622 | * @param Int $listID |
||
1623 | * @param Member | String $member |
||
1624 | * |
||
1625 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1626 | * { |
||
1627 | * 'EmailAddress' => The subscriber email address |
||
1628 | * 'Name' => The subscribers name |
||
1629 | * 'Date' => The date the subscriber was added to the list |
||
1630 | * 'State' => The current state of the subscriber |
||
1631 | * 'CustomFields' => array( |
||
1632 | * { |
||
1633 | * 'Key' => The custom fields personalisation tag |
||
1634 | * 'Value' => The custom field value for this subscriber |
||
1635 | * } |
||
1636 | * ) |
||
1637 | * } |
||
1638 | * |
||
1639 | */ |
||
1640 | public function getSubscriber($listID, $member, $cacheIsOK = true) |
||
1659 | |||
1660 | /** |
||
1661 | * Gets a subscriber details, including custom fields |
||
1662 | * |
||
1663 | * @param Int $listID |
||
1664 | * @param Member | String $member |
||
1665 | * |
||
1666 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
1667 | * { |
||
1668 | * 'EmailAddress' => The subscriber email address |
||
1669 | * 'Name' => The subscribers name |
||
1670 | * 'Date' => The date the subscriber was added to the list |
||
1671 | * 'State' => The current state of the subscriber |
||
1672 | * 'CustomFields' => array( |
||
1673 | * { |
||
1674 | * 'Key' => The custom fields personalisation tag |
||
1675 | * 'Value' => The custom field value for this subscriber |
||
1676 | * } |
||
1677 | * ) |
||
1678 | * } |
||
1679 | * |
||
1680 | */ |
||
1681 | View Code Duplication | public function getHistory($listID, $member) |
|
1694 | } |
||
1695 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.