← All changes
|
includes/Core/Integration/MailChimp/MailChimpHandler.php
+19
-10
2.0
→
2.15.3
View file →
| @@ -13,12 +13,14 @@ | ||
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Provide functionality for MailChimp integration |
| 16 | 16 | */ |
| 17 | -class MailChimpHandler { | |
| 17 | +class MailChimpHandler | |
| 18 | +{ | |
| 18 | 19 | private $_integrationID; |
| 19 | 20 | |
| 20 | - public function __construct($integrationID, $fromID) { | |
| 21 | + public function __construct($integrationID, $fromID) | |
| 22 | + { | |
| 21 | 23 | $this->_integrationID = $integrationID; |
| 22 | 24 | } |
| 23 | 25 | |
| 24 | 26 | /** |
| @@ -23,9 +25,10 @@ | ||
| 23 | 25 | |
| 24 | 26 | /** |
| 25 | 27 | * MailChimp API Endpoint |
| 26 | 28 | */ |
| 27 | - public static function apiEndPoint($dc) { | |
| 29 | + public static function apiEndPoint($dc) | |
| 30 | + { | |
| 28 | 31 | return "https://$dc.api.mailchimp.com/3.0"; |
| 29 | 32 | } |
| 30 | 33 | |
| 31 | 34 | /** |
| @@ -32,9 +35,10 @@ | ||
| 32 | 35 | * Helps to register ajax function's with wp |
| 33 | 36 | * |
| 34 | 37 | * @return null |
| 35 | 38 | */ |
| 36 | - public static function registerAjax() { | |
| 39 | + public static function registerAjax() | |
| 40 | + { | |
| 37 | 41 | add_action('wp_ajax_bitforms_mChimp_generate_token', [__CLASS__, 'generateTokens']); |
| 38 | 42 | add_action('wp_ajax_bitforms_mChimp_refresh_audience', [__CLASS__, 'refreshAudienceAjaxHelper']); |
| 39 | 43 | add_action('wp_ajax_bitforms_mChimp_refresh_fields', [__CLASS__, 'refreshAudienceFields']); |
| 40 | 44 | add_action('wp_ajax_bitforms_mChimp_refresh_tags', [__CLASS__, 'refreshTagsAjaxHelper']); |
| @@ -44,9 +48,10 @@ | ||
| 44 | 48 | * Process ajax request for generate_token |
| 45 | 49 | * |
| 46 | 50 | * @return JSON zoho crm api response and status |
| 47 | 51 | */ |
| 48 | - public static function generateTokens() { | |
| 52 | + public static function generateTokens() | |
| 53 | + { | |
| 49 | 54 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 50 | 55 | $authorizationHeader = null; |
| 51 | 56 | $inputJSON = file_get_contents('php://input'); |
| 52 | 57 | $requestsParams = json_decode($inputJSON); |
| @@ -106,9 +111,10 @@ | ||
| 106 | 111 | * Process ajax request for refresh MailChimp Audience list |
| 107 | 112 | * |
| 108 | 113 | * @return JSON MailChimp data |
| 109 | 114 | */ |
| 110 | - public static function refreshAudienceAjaxHelper() { | |
| 115 | + public static function refreshAudienceAjaxHelper() | |
| 116 | + { | |
| 111 | 117 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 112 | 118 | $authorizationHeader = null; |
| 113 | 119 | $inputJSON = file_get_contents('php://input'); |
| 114 | 120 | $queryParams = json_decode($inputJSON); |
| @@ -145,9 +151,9 @@ | ||
| 145 | 151 | } |
| 146 | 152 | uksort($allList, 'strnatcasecmp'); |
| 147 | 153 | |
| 148 | 154 | $response['audiencelist'] = $allList; |
| 149 | - // wp_send_json_success($response, 200); | |
| 155 | + // wp_send_json_success($response, 200); | |
| 150 | 156 | } else { |
| 151 | 157 | wp_send_json_error( |
| 152 | 158 | $audienceResponse->response->error->message, |
| 153 | 159 | 400 |
| @@ -168,9 +174,10 @@ | ||
| 168 | 174 | /** |
| 169 | 175 | * Process ajax request for refresh MailChimp Audince Fields |
| 170 | 176 | * @return JSON MailChimp Audience fields |
| 171 | 177 | */ |
| 172 | - public static function refreshAudienceFields() { | |
| 178 | + public static function refreshAudienceFields() | |
| 179 | + { | |
| 173 | 180 | $authorizationHeader = null; |
| 174 | 181 | $response = null; |
| 175 | 182 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 176 | 183 | $inputJSON = file_get_contents('php://input'); |
| @@ -223,9 +230,10 @@ | ||
| 223 | 230 | /** |
| 224 | 231 | * Process ajax request for refresh MailChimp Tags |
| 225 | 232 | * @return JSON MailChimp Tags |
| 226 | 233 | */ |
| 227 | - public static function refreshTagsAjaxHelper() { | |
| 234 | + public static function refreshTagsAjaxHelper() | |
| 235 | + { | |
| 228 | 236 | $authorizationHeader = null; |
| 229 | 237 | $response = null; |
| 230 | 238 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 231 | 239 | $inputJSON = file_get_contents('php://input'); |
| @@ -277,9 +285,10 @@ | ||
| 277 | 285 | * @param Obeject $tokenDetails refreshed token info |
| 278 | 286 | * |
| 279 | 287 | * @return null |
| 280 | 288 | */ |
| 281 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 289 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 290 | + { | |
| 282 | 291 | $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details; |
| 283 | 292 | |
| 284 | 293 | $tokenDetails = $integrationDetails->tokenDetails; |
| 285 | 294 | $listId = $integrationDetails->listId; |