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') |
||
| 340 | |||
| 341 | View Code Duplication | public function getTemplates() |
|
| 354 | |||
| 355 | View Code Duplication | public function getTemplate($templatID) |
|
| 368 | |||
| 369 | /** |
||
| 370 | * |
||
| 371 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
| 372 | * |
||
| 373 | * @return CS_REST_Wrapper_Result |
||
| 374 | */ |
||
| 375 | View Code Duplication | public function createTemplate($campaignMonitorCampaign) |
|
| 414 | |||
| 415 | /** |
||
| 416 | * |
||
| 417 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
| 418 | * @param string $templateID |
||
| 419 | * |
||
| 420 | * @return CS_REST_Wrapper_Result |
||
| 421 | */ |
||
| 422 | View Code Duplication | public function updateTemplate($campaignMonitorCampaign, $templateID) |
|
| 459 | |||
| 460 | View Code Duplication | public function deleteTemplate($templateID) |
|
| 470 | |||
| 471 | /******************************************************* |
||
| 472 | * lists |
||
| 473 | * |
||
| 474 | *******************************************************/ |
||
| 475 | |||
| 476 | /** |
||
| 477 | * Creates a new list based on the provided details. |
||
| 478 | * Both the UnsubscribePage and the ConfirmationSuccessPage parameters are optional |
||
| 479 | * |
||
| 480 | * @param string $title - the page to redirect subscribers to when they unsubscribeThe list title |
||
| 481 | * @param string $unsubscribePage - The page to redirect subscribers to when they unsubscribe |
||
| 482 | * @param boolean $confirmedOptIn - Whether this list requires confirmation of subscription |
||
| 483 | * @param string $confirmationSuccessPage - The page to redirect subscribers to when they confirm their subscription |
||
| 484 | * @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 |
||
| 485 | * |
||
| 486 | * @return CS_REST_Wrapper_Result A successful response will be the ID of the newly created list |
||
| 487 | */ |
||
| 488 | public function createList($title, $unsubscribePage, $confirmedOptIn = false, $confirmationSuccessPage, $unsubscribeSetting = null) |
||
| 513 | |||
| 514 | /** |
||
| 515 | * Creates custom field for list |
||
| 516 | * |
||
| 517 | * @param string $listID - list ID |
||
| 518 | * @param string $type - type of custom field |
||
| 519 | * @param string $title - field type |
||
| 520 | * @param array $options - options for dropdown field type |
||
| 521 | * |
||
| 522 | * @return CS_REST_Wrapper_Result A successful response will be the key of the newly created custom field |
||
| 523 | */ |
||
| 524 | public function createCustomField($listID, $visible, $type, $title, $options = array()) |
||
| 558 | |||
| 559 | /** |
||
| 560 | * Creates custom field for list |
||
| 561 | * |
||
| 562 | * @param string $listID - list ID |
||
| 563 | * @param string $key |
||
| 564 | * |
||
| 565 | * @return CS_REST_Wrapper_Result |
||
| 566 | */ |
||
| 567 | View Code Duplication | public function deleteCustomField($listID, $key) |
|
| 577 | |||
| 578 | /** |
||
| 579 | * Deletes an existing list from the system |
||
| 580 | * @param Int $listID |
||
| 581 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 582 | */ |
||
| 583 | View Code Duplication | public function deleteList($listID) |
|
| 594 | |||
| 595 | /** |
||
| 596 | * Gets the basic details of the current list |
||
| 597 | * |
||
| 598 | * @param Int $listID |
||
| 599 | * |
||
| 600 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 601 | * { |
||
| 602 | * 'ListID' => The id of the list |
||
| 603 | * 'Title' => The title of the list |
||
| 604 | * 'UnsubscribePage' => The page which subscribers are redirected to upon unsubscribing |
||
| 605 | * 'ConfirmedOptIn' => Whether the list is Double-Opt In |
||
| 606 | * 'ConfirmationSuccessPage' => The page which subscribers are |
||
| 607 | * redirected to upon confirming their subscription |
||
| 608 | * 'UnsubscribeSetting' => The unsubscribe setting for the list. Will |
||
| 609 | * be either CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS or |
||
| 610 | * CS_REST_LIST_UNSUBSCRIBE_SETTING_ONLY_THIS_LIST. |
||
| 611 | * } |
||
| 612 | */ |
||
| 613 | View Code Duplication | public function getList($listID) |
|
| 624 | |||
| 625 | /** |
||
| 626 | * Gets all active subscribers added since the given date |
||
| 627 | * |
||
| 628 | * @param Int $listID |
||
| 629 | * @param string $daysAgo The date to start getting subscribers from |
||
| 630 | * @param int $page The page number to get |
||
| 631 | * @param int $pageSize The number of records per page |
||
| 632 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 633 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 634 | * |
||
| 635 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 636 | * { |
||
| 637 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 638 | * 'OrderDirection' => The order direction |
||
| 639 | * 'PageNumber' => The page number for the result set |
||
| 640 | * 'PageSize' => The page size used |
||
| 641 | * 'RecordsOnThisPage' => The number of records returned |
||
| 642 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 643 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 644 | * 'Results' => array( |
||
| 645 | * { |
||
| 646 | * 'EmailAddress' => The email address of the subscriber |
||
| 647 | * 'Name' => The name of the subscriber |
||
| 648 | * 'Date' => The date that the subscriber was added to the list |
||
| 649 | * 'State' => The current state of the subscriber, will be 'Active' |
||
| 650 | * 'CustomFields' => array ( |
||
| 651 | * { |
||
| 652 | * 'Key' => The personalisation tag of the custom field |
||
| 653 | * 'Value' => The value of the custom field for this subscriber |
||
| 654 | * } |
||
| 655 | * ) |
||
| 656 | * } |
||
| 657 | * ) |
||
| 658 | * } |
||
| 659 | */ |
||
| 660 | View Code Duplication | public function getActiveSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
| 677 | |||
| 678 | /** |
||
| 679 | * Gets all unconfirmed subscribers added since the given date |
||
| 680 | * |
||
| 681 | * @param Int $listID |
||
| 682 | * @param string $daysAgo The date to start getting subscribers from |
||
| 683 | * @param int $page The page number to get |
||
| 684 | * @param int $pageSize The number of records per page |
||
| 685 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 686 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 687 | * |
||
| 688 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 689 | * { |
||
| 690 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 691 | * 'OrderDirection' => The order direction |
||
| 692 | * 'PageNumber' => The page number for the result set |
||
| 693 | * 'PageSize' => The page size used |
||
| 694 | * 'RecordsOnThisPage' => The number of records returned |
||
| 695 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 696 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 697 | * 'Results' => array( |
||
| 698 | * { |
||
| 699 | * 'EmailAddress' => The email address of the subscriber |
||
| 700 | * 'Name' => The name of the subscriber |
||
| 701 | * 'Date' => The date that the subscriber was added to the list |
||
| 702 | * 'State' => The current state of the subscriber, will be 'Unconfirmed' |
||
| 703 | * 'CustomFields' => array ( |
||
| 704 | * { |
||
| 705 | * 'Key' => The personalisation tag of the custom field |
||
| 706 | * 'Value' => The value of the custom field for this subscriber |
||
| 707 | * } |
||
| 708 | * ) |
||
| 709 | * } |
||
| 710 | * ) |
||
| 711 | * } |
||
| 712 | */ |
||
| 713 | View Code Duplication | public function getUnconfirmedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
| 730 | |||
| 731 | /** |
||
| 732 | * Gets all bounced subscribers who have bounced out since the given date |
||
| 733 | * |
||
| 734 | * @param Int $listID |
||
| 735 | * @param string $daysAgo The date to start getting subscribers from |
||
| 736 | * @param int $page The page number to get |
||
| 737 | * @param int $pageSize The number of records per page |
||
| 738 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 739 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 740 | * |
||
| 741 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 742 | * { |
||
| 743 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 744 | * 'OrderDirection' => The order direction |
||
| 745 | * 'PageNumber' => The page number for the result set |
||
| 746 | * 'PageSize' => The page size used |
||
| 747 | * 'RecordsOnThisPage' => The number of records returned |
||
| 748 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 749 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 750 | * 'Results' => array( |
||
| 751 | * { |
||
| 752 | * 'EmailAddress' => The email address of the subscriber |
||
| 753 | * 'Name' => The name of the subscriber |
||
| 754 | * 'Date' => The date that the subscriber bounced out of the list |
||
| 755 | * 'State' => The current state of the subscriber, will be 'Bounced' |
||
| 756 | * 'CustomFields' => array ( |
||
| 757 | * { |
||
| 758 | * 'Key' => The personalisation tag of the custom field |
||
| 759 | * 'Value' => The value of the custom field for this subscriber |
||
| 760 | * } |
||
| 761 | * ) |
||
| 762 | * } |
||
| 763 | * ) |
||
| 764 | * } |
||
| 765 | */ |
||
| 766 | View Code Duplication | public function getBouncedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
| 783 | |||
| 784 | |||
| 785 | /** |
||
| 786 | * Gets all unsubscribed subscribers who have unsubscribed since the given date |
||
| 787 | * |
||
| 788 | * @param Int $listID |
||
| 789 | * @param string $daysAgo The date to start getting subscribers from |
||
| 790 | * @param int $page The page number to get |
||
| 791 | * @param int $pageSize The number of records per page |
||
| 792 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 793 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 794 | * |
||
| 795 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 796 | * { |
||
| 797 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 798 | * 'OrderDirection' => The order direction |
||
| 799 | * 'PageNumber' => The page number for the result set |
||
| 800 | * 'PageSize' => The page size used |
||
| 801 | * 'RecordsOnThisPage' => The number of records returned |
||
| 802 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 803 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 804 | * 'Results' => array( |
||
| 805 | * { |
||
| 806 | * 'EmailAddress' => The email address of the subscriber |
||
| 807 | * 'Name' => The name of the subscriber |
||
| 808 | * 'Date' => The date that the subscriber was unsubscribed from the list |
||
| 809 | * 'State' => The current state of the subscriber, will be 'Unsubscribed' |
||
| 810 | * 'CustomFields' => array ( |
||
| 811 | * { |
||
| 812 | * 'Key' => The personalisation tag of the custom field |
||
| 813 | * 'Value' => The value of the custom field for this subscriber |
||
| 814 | * } |
||
| 815 | * ) |
||
| 816 | * } |
||
| 817 | * ) |
||
| 818 | * } |
||
| 819 | */ |
||
| 820 | View Code Duplication | public function getUnsubscribedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "DATE", $sortDirection = "DESC") |
|
| 837 | |||
| 838 | /** |
||
| 839 | * Gets all unsubscribed subscribers who have unsubscribed since the given date |
||
| 840 | * |
||
| 841 | * @param Int $listID |
||
| 842 | * @param string $daysAgo The date to start getting subscribers from |
||
| 843 | * @param int $page The page number to get |
||
| 844 | * @param int $pageSize The number of records per page |
||
| 845 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 846 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 847 | * |
||
| 848 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 849 | * { |
||
| 850 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 851 | * 'OrderDirection' => The order direction |
||
| 852 | * 'PageNumber' => The page number for the result set |
||
| 853 | * 'PageSize' => The page size used |
||
| 854 | * 'RecordsOnThisPage' => The number of records returned |
||
| 855 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 856 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 857 | * 'Results' => array( |
||
| 858 | * { |
||
| 859 | * 'EmailAddress' => The email address of the subscriber |
||
| 860 | * 'Name' => The name of the subscriber |
||
| 861 | * 'Date' => The date that the subscriber was unsubscribed from the list |
||
| 862 | * 'State' => The current state of the subscriber, will be 'Unsubscribed' |
||
| 863 | * 'CustomFields' => array ( |
||
| 864 | * { |
||
| 865 | * 'Key' => The personalisation tag of the custom field |
||
| 866 | * 'Value' => The value of the custom field for this subscriber |
||
| 867 | * } |
||
| 868 | * ) |
||
| 869 | * } |
||
| 870 | * ) |
||
| 871 | * } |
||
| 872 | */ |
||
| 873 | View Code Duplication | public function getDeletedSubscribers($listID, $daysAgo = 3650, $page = 1, $pageSize = 999, $sortByField = "email", $sortDirection = "asc") |
|
| 890 | |||
| 891 | /** |
||
| 892 | * Updates the details of an existing list |
||
| 893 | * Both the UnsubscribePage and the ConfirmationSuccessPage parameters are optional |
||
| 894 | * |
||
| 895 | * @param string $title - he page to redirect subscribers to when they unsubscribeThe list title |
||
| 896 | * @param string $unsubscribePage - The page to redirect subscribers to when they unsubscribe |
||
| 897 | * @param boolean $confirmedOptIn - Whether this list requires confirmation of subscription |
||
| 898 | * @param string $confirmationSuccessPage - The page to redirect subscribers to when they confirm their subscription |
||
| 899 | * @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 |
||
| 900 | * @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. |
||
| 901 | * @param boolean $acrubActiveWithSuppList - When UnsubscribeSetting is CS_REST_LIST_UNSUBSCRIBE_SETTING_ALL_CLIENT_LISTS, whether active subscribers should be scrubbed against the suppression list. |
||
| 902 | * |
||
| 903 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 904 | */ |
||
| 905 | public function updateList($listID, $title, $unsubscribePage, $confirmedOptIn = false, $confirmationSuccessPage, $unsubscribeSetting, $addUnsubscribesToSuppList = true, $scrubActiveWithSuppList = true) |
||
| 927 | |||
| 928 | View Code Duplication | public function getSegments($listID) |
|
| 941 | |||
| 942 | /** |
||
| 943 | * Gets statistics for list subscriptions, deletions, bounces and unsubscriptions |
||
| 944 | * |
||
| 945 | * @param Int $listID |
||
| 946 | * |
||
| 947 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 948 | * { |
||
| 949 | * 'TotalActiveSubscribers' |
||
| 950 | * 'NewActiveSubscribersToday' |
||
| 951 | * 'NewActiveSubscribersYesterday' |
||
| 952 | * 'NewActiveSubscribersThisWeek' |
||
| 953 | * 'NewActiveSubscribersThisMonth' |
||
| 954 | * 'NewActiveSubscribersThisYeay' |
||
| 955 | * 'TotalUnsubscribes' |
||
| 956 | * 'UnsubscribesToday' |
||
| 957 | * 'UnsubscribesYesterday' |
||
| 958 | * 'UnsubscribesThisWeek' |
||
| 959 | * 'UnsubscribesThisMonth' |
||
| 960 | * 'UnsubscribesThisYear' |
||
| 961 | * 'TotalDeleted' |
||
| 962 | * 'DeletedToday' |
||
| 963 | * 'DeletedYesterday' |
||
| 964 | * 'DeletedThisWeek' |
||
| 965 | * 'DeletedThisMonth' |
||
| 966 | * 'DeletedThisYear' |
||
| 967 | * 'TotalBounces' |
||
| 968 | * 'BouncesToday' |
||
| 969 | * 'BouncesYesterday' |
||
| 970 | * 'BouncesThisWeek' |
||
| 971 | * 'BouncesThisMonth' |
||
| 972 | * 'BouncesThisYear' |
||
| 973 | * } |
||
| 974 | */ |
||
| 975 | View Code Duplication | public function getListStats($listID) |
|
| 986 | |||
| 987 | View Code Duplication | public function getListCustomFields($listID) |
|
| 997 | |||
| 998 | /******************************************************* |
||
| 999 | * create campaigns |
||
| 1000 | * |
||
| 1001 | *******************************************************/ |
||
| 1002 | |||
| 1003 | /** |
||
| 1004 | * |
||
| 1005 | * |
||
| 1006 | * @param CampaignMonitorCampaign $campaignMonitorCampaign |
||
| 1007 | * @param array listIDs |
||
| 1008 | * @param array segmentIDs |
||
| 1009 | * @param string templateID - OPTIONAL! |
||
| 1010 | * @param array templateContent - OPTIONAL! |
||
| 1011 | */ |
||
| 1012 | public function createCampaign( |
||
| 1101 | |||
| 1102 | View Code Duplication | public function deleteCampaign($campaignID) |
|
| 1112 | |||
| 1113 | /******************************************************* |
||
| 1114 | * information about the campaigns |
||
| 1115 | * |
||
| 1116 | *******************************************************/ |
||
| 1117 | |||
| 1118 | public function getBounces() |
||
| 1122 | |||
| 1123 | public function getClicks() |
||
| 1127 | |||
| 1128 | /** |
||
| 1129 | * Gets a summary of all campaign reporting statistics |
||
| 1130 | * |
||
| 1131 | * @param int $campaignID |
||
| 1132 | * |
||
| 1133 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1134 | * { |
||
| 1135 | * 'Recipients' => The total recipients of the campaign |
||
| 1136 | * 'TotalOpened' => The total number of opens recorded |
||
| 1137 | * 'Clicks' => The total number of recorded clicks |
||
| 1138 | * 'Unsubscribed' => The number of recipients who unsubscribed |
||
| 1139 | * 'Bounced' => The number of recipients who bounced |
||
| 1140 | * 'UniqueOpened' => The number of recipients who opened |
||
| 1141 | * 'WebVersionURL' => The url of the web version of the campaign |
||
| 1142 | * 'WebVersionTextURL' => The url of the web version of the text version of the campaign |
||
| 1143 | * 'WorldviewURL' => The public Worldview URL for the campaign |
||
| 1144 | * 'Forwards' => The number of times the campaign has been forwarded to a friend |
||
| 1145 | * 'Likes' => The number of times the campaign has been 'liked' on Facebook |
||
| 1146 | * 'Mentions' => The number of times the campaign has been tweeted about |
||
| 1147 | * 'SpamComplaints' => The number of recipients who marked the campaign as spam |
||
| 1148 | * } |
||
| 1149 | */ |
||
| 1150 | View Code Duplication | public function getSummary($campaignID) |
|
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Gets the email clients that subscribers used to open the campaign |
||
| 1163 | * |
||
| 1164 | * @param Int $campaignID |
||
| 1165 | * |
||
| 1166 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1167 | * array( |
||
| 1168 | * { |
||
| 1169 | * Client => The email client name |
||
| 1170 | * Version => The email client version |
||
| 1171 | * Percentage => The percentage of subscribers who used this email client |
||
| 1172 | * Subscribers => The actual number of subscribers who used this email client |
||
| 1173 | * } |
||
| 1174 | * ) |
||
| 1175 | */ |
||
| 1176 | View Code Duplication | public function getEmailClientUsage($campaignID) |
|
| 1186 | |||
| 1187 | public function getListsAndSegments() |
||
| 1191 | |||
| 1192 | public function getOpens() |
||
| 1196 | |||
| 1197 | public function getRecipients() |
||
| 1201 | |||
| 1202 | public function getSpam() |
||
| 1206 | |||
| 1207 | /** |
||
| 1208 | * Gets all unsubscribes recorded for a campaign since the provided date |
||
| 1209 | * |
||
| 1210 | * @param int $campaignID ID of the Campaign |
||
| 1211 | * @param string $daysAgo The date to start getting subscribers from |
||
| 1212 | * @param int $page The page number to get |
||
| 1213 | * @param int $pageSize The number of records per page |
||
| 1214 | * @param string $sortByField ('EMAIL', 'NAME', 'DATE') |
||
| 1215 | * @param string $sortDirection ('ASC', 'DESC') |
||
| 1216 | * |
||
| 1217 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1218 | * { |
||
| 1219 | * 'ResultsOrderedBy' => The field the results are ordered by |
||
| 1220 | * 'OrderDirection' => The order direction |
||
| 1221 | * 'PageNumber' => The page number for the result set |
||
| 1222 | * 'PageSize' => The page size used |
||
| 1223 | * 'RecordsOnThisPage' => The number of records returned |
||
| 1224 | * 'TotalNumberOfRecords' => The total number of records available |
||
| 1225 | * 'NumberOfPages' => The total number of pages for this collection |
||
| 1226 | * 'Results' => array( |
||
| 1227 | * { |
||
| 1228 | * 'EmailAddress' => The email address of the subscriber who unsubscribed |
||
| 1229 | * 'ListID' => The list id of the list containing the subscriber |
||
| 1230 | * 'Date' => The date of the unsubscribe |
||
| 1231 | * 'IPAddress' => The ip address where the unsubscribe originated |
||
| 1232 | * } |
||
| 1233 | * ) |
||
| 1234 | * } |
||
| 1235 | */ |
||
| 1236 | View Code Duplication | public function getUnsubscribes($campaignID, $daysAgo = 3650, $page =1, $pageSize = 999, $sortByField = "EMAIL", $sortDirection = "ASC") |
|
| 1253 | |||
| 1254 | |||
| 1255 | |||
| 1256 | /******************************************************* |
||
| 1257 | * user |
||
| 1258 | * |
||
| 1259 | * states: |
||
| 1260 | * |
||
| 1261 | * Active – Someone who is on a list and will receive any emails sent to that list. |
||
| 1262 | * |
||
| 1263 | * Unconfirmed – The individual signed up to a confirmed opt-in list |
||
| 1264 | * but has not clicked the link in the verification email sent to them. |
||
| 1265 | * |
||
| 1266 | * Unsubscribed – The subscriber has removed themselves from a list, or lists, |
||
| 1267 | * via an unsubscribe link or form. |
||
| 1268 | * You can also change a subscriber's status to unsubscribed through your account. |
||
| 1269 | * |
||
| 1270 | * Bounced – This describes an email address that campaigns cannot be delivered to, |
||
| 1271 | * which can happen for a number of reasons. |
||
| 1272 | * |
||
| 1273 | * Deleted – Means the subscriber has been deleted from a list through your account. |
||
| 1274 | * |
||
| 1275 | *******************************************************/ |
||
| 1276 | |||
| 1277 | /** |
||
| 1278 | * Gets the lists across a client to which a subscriber with a particular |
||
| 1279 | * email address belongs. |
||
| 1280 | * |
||
| 1281 | * @param string | Member $email Subscriber's email address (or Member) |
||
| 1282 | * |
||
| 1283 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1284 | * array( |
||
| 1285 | * { |
||
| 1286 | * 'ListID' => The id of the list |
||
| 1287 | * 'ListName' => The name of the list |
||
| 1288 | * 'SubscriberState' => The state of the subscriber in the list |
||
| 1289 | * 'DateSubscriberAdded' => The date the subscriber was added |
||
| 1290 | * } |
||
| 1291 | * ) |
||
| 1292 | */ |
||
| 1293 | public function getListsForEmail($member) |
||
| 1307 | |||
| 1308 | |||
| 1309 | /** |
||
| 1310 | * Adds a new subscriber to the specified list |
||
| 1311 | * |
||
| 1312 | * @param Int $listID |
||
| 1313 | * @param Member $member |
||
| 1314 | * @param Array $customFields |
||
| 1315 | * @param array $customFields The subscriber details to use during creation. |
||
| 1316 | * @param boolean $resubscribe Whether we should resubscribe this subscriber if they already exist in the list |
||
| 1317 | * @param boolean $RestartSubscriptionBasedAutoResponders Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. |
||
| 1318 | * |
||
| 1319 | * NOTE that for the custom fields they need to be formatted like this: |
||
| 1320 | * Array( |
||
| 1321 | * 'Key' => The custom fields personalisation tag |
||
| 1322 | * 'Value' => The value for this subscriber |
||
| 1323 | * '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) |
||
| 1324 | * ) |
||
| 1325 | * |
||
| 1326 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 1327 | */ |
||
| 1328 | public function addSubscriber( |
||
| 1362 | |||
| 1363 | /** |
||
| 1364 | * Updates an existing subscriber (email, name, state, or custom fields) in the specified list. |
||
| 1365 | * The update is performed even for inactive subscribers, but will return an error in the event of the |
||
| 1366 | * given email not existing in the list. |
||
| 1367 | * |
||
| 1368 | * @param Int $listID |
||
| 1369 | * @param String $oldEmailAddress |
||
| 1370 | * @param Member $member |
||
| 1371 | * @param array $customFields The subscriber details to use during creation. |
||
| 1372 | * @param boolean $resubscribe Whether we should resubscribe this subscriber if they already exist in the list |
||
| 1373 | * @param boolean $restartSubscriptionBasedAutoResponders Whether we should restart subscription based auto responders which are sent when the subscriber first subscribes to a list. |
||
| 1374 | * |
||
| 1375 | * NOTE that for the custom fields they need to be formatted like this: |
||
| 1376 | * Array( |
||
| 1377 | * 'Key' => The custom fields personalisation tag |
||
| 1378 | * 'Value' => The value for this subscriber |
||
| 1379 | * '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) |
||
| 1380 | * ) |
||
| 1381 | * |
||
| 1382 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 1383 | */ |
||
| 1384 | public function updateSubscriber( |
||
| 1423 | |||
| 1424 | /** |
||
| 1425 | * Updates an existing subscriber (email, name, state, or custom fields) in the specified list. |
||
| 1426 | * The update is performed even for inactive subscribers, but will return an error in the event of the |
||
| 1427 | * given email not existing in the list. |
||
| 1428 | * |
||
| 1429 | * @param Int $listID |
||
| 1430 | * @param ArraySet $memberSet - list of mebers |
||
| 1431 | * @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] ) ) |
||
| 1432 | * @param $resubscribe Whether we should resubscribe any existing subscribers |
||
| 1433 | * @param $queueSubscriptionBasedAutoResponders By default, subscription based auto responders do not trigger during an import. Pass a value of true to override this behaviour |
||
| 1434 | * @param $restartSubscriptionBasedAutoResponders By default, subscription based auto responders will not be restarted |
||
| 1435 | * |
||
| 1436 | * NOTE that for the custom fields they need to be formatted like this: |
||
| 1437 | * Array( |
||
| 1438 | * 'Key' => The custom fields personalisation tag |
||
| 1439 | * 'Value' => The value for this subscriber |
||
| 1440 | * '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) |
||
| 1441 | * ) |
||
| 1442 | |||
| 1443 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 1444 | */ |
||
| 1445 | public function addSubscribers( |
||
| 1493 | |||
| 1494 | /** |
||
| 1495 | * @param Int $listID |
||
| 1496 | * @param Member | String $member - email address or Member Object |
||
| 1497 | * |
||
| 1498 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 1499 | */ |
||
| 1500 | View Code Duplication | public function deleteSubscriber($listID, $member) |
|
| 1513 | |||
| 1514 | /** |
||
| 1515 | * Unsubscribes the given subscriber from the current list |
||
| 1516 | * |
||
| 1517 | * @param Int $listID |
||
| 1518 | * @param Member | String $member |
||
| 1519 | * |
||
| 1520 | * @return CS_REST_Wrapper_Result A successful response will be empty |
||
| 1521 | */ |
||
| 1522 | View Code Duplication | public function unsubscribeSubscriber($listID, $member) |
|
| 1535 | |||
| 1536 | /** |
||
| 1537 | * Is this user part of this list at all? |
||
| 1538 | * |
||
| 1539 | * @param Int $listID |
||
| 1540 | * @param Member | String $member |
||
| 1541 | * |
||
| 1542 | * @return Boolean |
||
| 1543 | */ |
||
| 1544 | View Code Duplication | public function getSubscriberExistsForThisList($listID, $member) |
|
| 1561 | |||
| 1562 | /** |
||
| 1563 | * Can we send e-mails to this person in the future for this list? |
||
| 1564 | * |
||
| 1565 | * @param Int $listID |
||
| 1566 | * @param Member | String $member |
||
| 1567 | * |
||
| 1568 | * @return Boolean |
||
| 1569 | */ |
||
| 1570 | View Code Duplication | public function getSubscriberCanReceiveEmailsForThisList($listID, $member) |
|
| 1589 | |||
| 1590 | /** |
||
| 1591 | * This e-mail / user has been banned from a list. |
||
| 1592 | * |
||
| 1593 | * @param Int $listID |
||
| 1594 | * @param Member | String $member |
||
| 1595 | * |
||
| 1596 | * @return Boolean |
||
| 1597 | */ |
||
| 1598 | public function getSubscriberCanNoLongerReceiveEmailsForThisList($listID, $member) |
||
| 1615 | |||
| 1616 | private static $_get_subscriber = array(); |
||
| 1617 | |||
| 1618 | /** |
||
| 1619 | * Gets a subscriber details, including custom fields |
||
| 1620 | * |
||
| 1621 | * @param Int $listID |
||
| 1622 | * @param Member | String $member |
||
| 1623 | * |
||
| 1624 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1625 | * { |
||
| 1626 | * 'EmailAddress' => The subscriber email address |
||
| 1627 | * 'Name' => The subscribers name |
||
| 1628 | * 'Date' => The date the subscriber was added to the list |
||
| 1629 | * 'State' => The current state of the subscriber |
||
| 1630 | * 'CustomFields' => array( |
||
| 1631 | * { |
||
| 1632 | * 'Key' => The custom fields personalisation tag |
||
| 1633 | * 'Value' => The custom field value for this subscriber |
||
| 1634 | * } |
||
| 1635 | * ) |
||
| 1636 | * } |
||
| 1637 | * |
||
| 1638 | */ |
||
| 1639 | public function getSubscriber($listID, $member, $cacheIsOK = true) |
||
| 1658 | |||
| 1659 | /** |
||
| 1660 | * Gets a subscriber details, including custom fields |
||
| 1661 | * |
||
| 1662 | * @param Int $listID |
||
| 1663 | * @param Member | String $member |
||
| 1664 | * |
||
| 1665 | * @return CS_REST_Wrapper_Result A successful response will be an object of the form |
||
| 1666 | * { |
||
| 1667 | * 'EmailAddress' => The subscriber email address |
||
| 1668 | * 'Name' => The subscribers name |
||
| 1669 | * 'Date' => The date the subscriber was added to the list |
||
| 1670 | * 'State' => The current state of the subscriber |
||
| 1671 | * 'CustomFields' => array( |
||
| 1672 | * { |
||
| 1673 | * 'Key' => The custom fields personalisation tag |
||
| 1674 | * 'Value' => The custom field value for this subscriber |
||
| 1675 | * } |
||
| 1676 | * ) |
||
| 1677 | * } |
||
| 1678 | * |
||
| 1679 | */ |
||
| 1680 | View Code Duplication | public function getHistory($listID, $member) |
|
| 1693 | } |
||
| 1694 |
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.