← All changes
|
includes/Core/Integration/ElasticEmail/ElasticEmailHandler.php
+13
-7
2.0
→
2.15.3
View file →
| @@ -12,15 +12,18 @@ | ||
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | 14 | * Provide functionality for ZohoCrm integration |
| 15 | 15 | */ |
| 16 | -class ElasticEmailHandler { | |
| 17 | - public static function registerAjax() { | |
| 16 | +class ElasticEmailHandler | |
| 17 | +{ | |
| 18 | + public static function registerAjax() | |
| 19 | + { | |
| 18 | 20 | add_action('wp_ajax_bitforms_elasticemail_authorize', [__CLASS__, 'elasticEmailAuthorize']); |
| 19 | 21 | add_action('wp_ajax_bitforms_get_all_lists', [__CLASS__, 'getAllLists']); |
| 20 | 22 | } |
| 21 | 23 | |
| 22 | - public static function elasticEmailAuthorize() { | |
| 24 | + public static function elasticEmailAuthorize() | |
| 25 | + { | |
| 23 | 26 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 24 | 27 | $inputJSON = file_get_contents('php://input'); |
| 25 | 28 | $requestsParams = json_decode($inputJSON); |
| 26 | 29 | |
| @@ -36,15 +39,16 @@ | ||
| 36 | 39 | |
| 37 | 40 | $apiEndpoint = 'https://api.elasticemail.com/v4/lists'; |
| 38 | 41 | $apiKey = $requestsParams->api_key; |
| 39 | 42 | $header = [ |
| 40 | - 'X-ElasticEmail-ApiKey' => 22423423423423423, | |
| 43 | + 'X-ElasticEmail-ApiKey' => $apiKey, | |
| 41 | 44 | 'Accept' => '*/*', |
| 42 | 45 | ]; |
| 43 | 46 | $apiResponse = HttpHelper::get($apiEndpoint, null, $header); |
| 47 | + | |
| 44 | 48 | if (is_wp_error($apiResponse) || isset($apiResponse->Error)) { |
| 45 | 49 | wp_send_json_error( |
| 46 | - empty($apiResponse->code) ? 'Unknown' : $apiResponse->Error, | |
| 50 | + $apiResponse->Error, | |
| 47 | 51 | 400 |
| 48 | 52 | ); |
| 49 | 53 | } |
| 50 | 54 | wp_send_json_success(true); |
| @@ -50,9 +54,10 @@ | ||
| 50 | 54 | wp_send_json_success(true); |
| 51 | 55 | } |
| 52 | 56 | } |
| 53 | 57 | |
| 54 | - public static function getAllLists() { | |
| 58 | + public static function getAllLists() | |
| 59 | + { | |
| 55 | 60 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 56 | 61 | $response = null; |
| 57 | 62 | $inputJSON = file_get_contents('php://input'); |
| 58 | 63 | $requestsParams = json_decode($inputJSON); |
| @@ -87,9 +92,10 @@ | ||
| 87 | 92 | |
| 88 | 93 | // wp_send_json_success(true); |
| 89 | 94 | } |
| 90 | 95 | |
| 91 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 96 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 97 | + { | |
| 92 | 98 | $integrationDetails = $integrationData->integration_details; |
| 93 | 99 | if (is_string($integrationDetails)) { |
| 94 | 100 | $integrationDetails = json_decode($integrationDetails); |
| 95 | 101 | } |