← All changes
|
includes/Core/Integration/ActiveCampaign/ActiveCampaignHandler.php
+20
-11
2.0
→
2.15.3
View file →
| @@ -13,13 +13,15 @@ | ||
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Provide functionality for ZohoCrm integration |
| 16 | 16 | */ |
| 17 | -class ActiveCampaignHandler { | |
| 17 | +class ActiveCampaignHandler | |
| 18 | +{ | |
| 18 | 19 | private $_formID; |
| 19 | 20 | private $_integrationID; |
| 20 | 21 | |
| 21 | - public function __construct($integrationID, $fromID) { | |
| 22 | + public function __construct($integrationID, $fromID) | |
| 23 | + { | |
| 22 | 24 | $this->_formID = $fromID; |
| 23 | 25 | $this->_integrationID = $integrationID; |
| 24 | 26 | } |
| 25 | 27 | |
| @@ -27,9 +29,10 @@ | ||
| 27 | 29 | * Helps to register ajax function's with wp |
| 28 | 30 | * |
| 29 | 31 | * @return null |
| 30 | 32 | */ |
| 31 | - public static function registerAjax() { | |
| 33 | + public static function registerAjax() | |
| 34 | + { | |
| 32 | 35 | add_action('wp_ajax_bitforms_aCampaign_authorize', [__CLASS__, 'activeCampaignAuthorize']); |
| 33 | 36 | add_action('wp_ajax_bitforms_aCampaign_headers', [__CLASS__, 'activeCampaignHeaders']); |
| 34 | 37 | add_action('wp_ajax_bitforms_aCampaign_lists', [__CLASS__, 'activeCampaignLists']); |
| 35 | 38 | add_action('wp_ajax_bitforms_aCampaign_tags', [__CLASS__, 'activeCampaignTags']); |
| @@ -34,9 +37,10 @@ | ||
| 34 | 37 | add_action('wp_ajax_bitforms_aCampaign_lists', [__CLASS__, 'activeCampaignLists']); |
| 35 | 38 | add_action('wp_ajax_bitforms_aCampaign_tags', [__CLASS__, 'activeCampaignTags']); |
| 36 | 39 | } |
| 37 | 40 | |
| 38 | - public static function _apiEndpoint($api_url, $method) { | |
| 41 | + public static function _apiEndpoint($api_url, $method) | |
| 42 | + { | |
| 39 | 43 | return "{$api_url}/api/3/{$method}/"; |
| 40 | 44 | } |
| 41 | 45 | |
| 42 | 46 | /** |
| @@ -41,11 +45,12 @@ | ||
| 41 | 45 | |
| 42 | 46 | /** |
| 43 | 47 | * Process ajax request |
| 44 | 48 | * |
| 45 | - * @return JSON Active Campaign api response and status | |
| 49 | + * @return string Active Campaign api response and status | |
| 46 | 50 | */ |
| 47 | - public static function activeCampaignAuthorize() { | |
| 51 | + public static function activeCampaignAuthorize() | |
| 52 | + { | |
| 48 | 53 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 49 | 54 | $inputJSON = file_get_contents('php://input'); |
| 50 | 55 | $requestsParams = json_decode($inputJSON); |
| 51 | 56 | if ( |
| @@ -89,9 +94,10 @@ | ||
| 89 | 94 | * Process ajax request for refresh lists |
| 90 | 95 | * |
| 91 | 96 | * @return JSON active campaign list data |
| 92 | 97 | */ |
| 93 | - public static function activeCampaignLists() { | |
| 98 | + public static function activeCampaignLists() | |
| 99 | + { | |
| 94 | 100 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 95 | 101 | $inputJSON = file_get_contents('php://input'); |
| 96 | 102 | $queryParams = json_decode($inputJSON); |
| 97 | 103 | |
| @@ -142,9 +148,10 @@ | ||
| 142 | 148 | * Process ajax request for refresh Tags |
| 143 | 149 | * |
| 144 | 150 | * @return JSON active campaign tags data |
| 145 | 151 | */ |
| 146 | - public static function activeCampaignTags() { | |
| 152 | + public static function activeCampaignTags() | |
| 153 | + { | |
| 147 | 154 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 148 | 155 | $inputJSON = file_get_contents('php://input'); |
| 149 | 156 | $queryParams = json_decode($inputJSON); |
| 150 | 157 | |
| @@ -160,9 +167,9 @@ | ||
| 160 | 167 | 400 |
| 161 | 168 | ); |
| 162 | 169 | } |
| 163 | 170 | |
| 164 | - $apiEndpoint = self::_apiEndpoint($queryParams->api_url, 'tags'); | |
| 171 | + $apiEndpoint = self::_apiEndpoint($queryParams->api_url, 'tags?limit=500'); | |
| 165 | 172 | $authorizationHeader = []; |
| 166 | 173 | $authorizationHeader['Api-Token'] = $queryParams->api_key; |
| 167 | 174 | $aCampaignResponse = HttpHelper::get($apiEndpoint, null, $authorizationHeader); |
| 168 | 175 | |
| @@ -195,9 +202,10 @@ | ||
| 195 | 202 | * Process ajax request for refresh crm modules |
| 196 | 203 | * |
| 197 | 204 | * @return JSON crm module data |
| 198 | 205 | */ |
| 199 | - public static function activeCampaignHeaders() { | |
| 206 | + public static function activeCampaignHeaders() | |
| 207 | + { | |
| 200 | 208 | $authorizationHeader = null; |
| 201 | 209 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 202 | 210 | $inputJSON = file_get_contents('php://input'); |
| 203 | 211 | $queryParams = json_decode($inputJSON); |
| @@ -249,9 +257,10 @@ | ||
| 249 | 257 | ); |
| 250 | 258 | } |
| 251 | 259 | } |
| 252 | 260 | |
| 253 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 261 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 262 | + { | |
| 254 | 263 | $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details; |
| 255 | 264 | $api_key = $integrationDetails->api_key; |
| 256 | 265 | $api_url = $integrationDetails->api_url; |
| 257 | 266 | $fieldMap = $integrationDetails->field_map; |