← All changes
|
includes/Core/Integration/ZohoSign/ZohoSignHandler.php
+24
-15
2.0
→
2.15.3
View file →
| @@ -14,13 +14,15 @@ | ||
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Provide functionality for ZohoCrm integration |
| 17 | 17 | */ |
| 18 | -class ZohoSignHandler { | |
| 18 | +class ZohoSignHandler | |
| 19 | +{ | |
| 19 | 20 | private $_formID; |
| 20 | 21 | private $_integrationID; |
| 21 | 22 | |
| 22 | - public function __construct($integrationID, $fromID) { | |
| 23 | + public function __construct($integrationID, $fromID) | |
| 24 | + { | |
| 23 | 25 | $this->_formID = $fromID; |
| 24 | 26 | $this->_integrationID = $integrationID; |
| 25 | 27 | } |
| 26 | 28 | |
| @@ -28,9 +30,10 @@ | ||
| 28 | 30 | * Helps to register ajax function's with wp |
| 29 | 31 | * |
| 30 | 32 | * @return null |
| 31 | 33 | */ |
| 32 | - public static function registerAjax() { | |
| 34 | + public static function registerAjax() | |
| 35 | + { | |
| 33 | 36 | add_action('wp_ajax_bitforms_zsign_generate_token', [__CLASS__, 'generateTokens']); |
| 34 | 37 | add_action('wp_ajax_bitforms_zsign_refresh_templates', [__CLASS__, 'refreshTemplatesAjaxHelper']); |
| 35 | 38 | add_action('wp_ajax_bitforms_zsign_refresh_template_details', [__CLASS__, 'refreshTemplateDetailsAjaxHelper']); |
| 36 | 39 | } |
| @@ -39,9 +42,10 @@ | ||
| 39 | 42 | * Process ajax request for generate_token |
| 40 | 43 | * |
| 41 | 44 | * @return JSON zoho crm api response and status |
| 42 | 45 | */ |
| 43 | - public static function generateTokens() { | |
| 46 | + public static function generateTokens() | |
| 47 | + { | |
| 44 | 48 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 45 | 49 | $inputJSON = file_get_contents('php://input'); |
| 46 | 50 | $requestsParams = json_decode($inputJSON); |
| 47 | 51 | if ( |
| @@ -92,12 +96,13 @@ | ||
| 92 | 96 | |
| 93 | 97 | /** |
| 94 | 98 | * Helps to refresh zoho crm access_token |
| 95 | 99 | * |
| 96 | - * @param Array $apiData Contains required data for refresh access token | |
| 97 | - * @return JSON $tokenDetails API token details | |
| 100 | + * @param object $apiData Contains required data for refresh access token | |
| 101 | + * @return string|boolean $tokenDetails API token details | |
| 98 | 102 | */ |
| 99 | - protected static function _refreshAccessToken($apiData) { | |
| 103 | + protected static function _refreshAccessToken($apiData) | |
| 104 | + { | |
| 100 | 105 | if ( |
| 101 | 106 | empty($apiData->dataCenter) |
| 102 | 107 | || empty($apiData->clientId) |
| 103 | 108 | || empty($apiData->clientSecret) |
| @@ -127,15 +132,16 @@ | ||
| 127 | 132 | |
| 128 | 133 | /** |
| 129 | 134 | * Save updated access_token to avoid unnecessary token generation |
| 130 | 135 | * |
| 131 | - * @param Integer $fromID ID of Integration related form | |
| 132 | - * @param Integer $integrationID ID of Zoho crm Integration | |
| 133 | - * @param Obeject $tokenDetails refreshed token info | |
| 136 | + * @param integer $fromID ID of Integration related form | |
| 137 | + * @param integer $integrationID ID of Zoho crm Integration | |
| 138 | + * @param object $tokenDetails refreshed token info | |
| 134 | 139 | * |
| 135 | 140 | * @return null |
| 136 | 141 | */ |
| 137 | - protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) { | |
| 142 | + protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null) | |
| 143 | + { | |
| 138 | 144 | if (empty($formID) || empty($integrationID)) { |
| 139 | 145 | return; |
| 140 | 146 | } |
| 141 | 147 | |
| @@ -148,12 +154,13 @@ | ||
| 148 | 154 | $newDetails = json_decode($zsignDetails[0]->integration_details); |
| 149 | 155 | |
| 150 | 156 | $newDetails->tokenDetails = $tokenDetails; |
| 151 | 157 | |
| 152 | - $integrationHandler->updateIntegration($integrationID, $zsignDetails[0]->integration_name, 'Zoho Sign', \json_encode($newDetails), 'form'); | |
| 158 | + $integrationHandler->updateIntegration($integrationID, $zsignDetails[0]->integration_name, 'Zoho Sign', wp_json_encode($newDetails), 'form'); | |
| 153 | 159 | } |
| 154 | 160 | |
| 155 | - public function refreshTemplatesAjaxHelper() { | |
| 161 | + public static function refreshTemplatesAjaxHelper() | |
| 162 | + { | |
| 156 | 163 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 157 | 164 | $authorizationHeader = null; |
| 158 | 165 | $inputJSON = file_get_contents('php://input'); |
| 159 | 166 | $queryParams = json_decode($inputJSON); |
| @@ -212,9 +219,10 @@ | ||
| 212 | 219 | ); |
| 213 | 220 | } |
| 214 | 221 | } |
| 215 | 222 | |
| 216 | - public function refreshTemplateDetailsAjaxHelper() { | |
| 223 | + public static function refreshTemplateDetailsAjaxHelper() | |
| 224 | + { | |
| 217 | 225 | if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce($_REQUEST['_ajax_nonce'], 'bitforms_save')) { |
| 218 | 226 | $authorizationHeader = null; |
| 219 | 227 | $inputJSON = file_get_contents('php://input'); |
| 220 | 228 | $queryParams = json_decode($inputJSON); |
| @@ -273,9 +281,10 @@ | ||
| 273 | 281 | ); |
| 274 | 282 | } |
| 275 | 283 | } |
| 276 | 284 | |
| 277 | - public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) { | |
| 285 | + public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID) | |
| 286 | + { | |
| 278 | 287 | $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details; |
| 279 | 288 | $templateActions = $integrationDetails->templateActions; |
| 280 | 289 | $notes = $integrationDetails->notes; |
| 281 | 290 | $dataCenter = $integrationDetails->dataCenter; |