PluginProbe
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder / V-3.3.0
Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder vV-3.3.0
3.3.1 V-3.3.0 3.2.2 3.2.1 3.2.0 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 V3.0.3 V3.0.2 -3.0.1 V_3.0.0 1.1.1 1.1.8 1.2 1.3 1.4 1.4.18 1.5.2 1.9 2.0 2.10.0 2.10.1 All 138 releases
bit-form / includes / Core / Integration / ZohoBigin / ZohoBiginHandler.php

ZohoBiginHandler.php in Bit Form – Contact Form, Payment Forms, Multi Step Forms, Calculator & Custom Form Builder V-3.3.0, at includes/Core/Integration/ZohoBigin/ZohoBiginHandler.php

696 lines 23.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * ZohoBigin Integration
5 *
6 */
7
8 namespace BitCode\BitForm\Core\Integration\ZohoBigin;
9
10 if (!defined('ABSPATH')) {
11 exit;
12 }
13
14 use BitCode\BitForm\Core\Integration\IntegrationHandler;
15 use BitCode\BitForm\Core\Util\ApiResponse as UtilApiResponse;
16 use BitCode\BitForm\Core\Util\HttpHelper;
17 use BitCode\BitForm\Core\Util\IpTool;
18 use BitCode\BitForm\GlobalHelper;
19 use WP_Error;
20
21 /**
22 * Provide functionality for ZohoCrm integration
23 */
24 class ZohoBiginHandler
25 {
26 private $_formID;
27 private $_integrationID;
28 private $_logResponse;
29
30 public function __construct($integrationID, $fromID)
31 {
32 $this->_formID = $fromID;
33 $this->_integrationID = $integrationID;
34 $this->_logResponse = new UtilApiResponse();
35 }
36
37 /**
38 * Helps to register ajax function's with wp
39 *
40 * @return null
41 */
42 public static function registerAjax()
43 {
44 add_action('wp_ajax_bitforms_zbigin_generate_token', [__CLASS__, 'generateTokens']);
45 add_action('wp_ajax_bitforms_zbigin_refresh_modules', [__CLASS__, 'refreshModulesAjaxHelper']);
46 add_action('wp_ajax_bitforms_zbigin_refresh_related_lists', [__CLASS__, 'refreshRelatedModulesAjaxHelper']);
47 add_action('wp_ajax_bitforms_zbigin_refresh_fields', [__CLASS__, 'getFields']);
48 add_action('wp_ajax_bitforms_zbigin_refresh_tags', [__CLASS__, 'getTagList']);
49 add_action('wp_ajax_bitforms_zbigin_refresh_users', [__CLASS__, 'getUsers']);
50 }
51
52 /**
53 * Process ajax request for generate_token
54 *
55 * @return JSON zoho bigin api response and status
56 */
57 public static function generateTokens()
58 {
59 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
60 GlobalHelper::requirePostMethod();
61
62 try {
63 $requestsParams = GlobalHelper::formatRequestData();
64 } catch (\InvalidArgumentException $e) {
65 wp_send_json_error($e->getMessage(), 400);
66 }
67
68 if (
69 empty($requestsParams->{'accounts-server'})
70 || empty($requestsParams->dataCenter)
71 || empty($requestsParams->clientId)
72 || empty($requestsParams->clientSecret)
73 || empty($requestsParams->redirectURI)
74 || empty($requestsParams->code)
75 ) {
76 wp_send_json_error(
77 __(
78 'Requested parameter is empty',
79 'bit-form'
80 ),
81 400
82 );
83 }
84
85 $apiEndpoint = \urldecode($requestsParams->{'accounts-server'}) . '/oauth/v2/token';
86 $requestParams = [
87 'grant_type' => 'authorization_code',
88 'client_id' => $requestsParams->clientId,
89 'client_secret' => $requestsParams->clientSecret,
90 'redirect_uri' => \urldecode($requestsParams->redirectURI),
91 'code' => $requestsParams->code
92 ];
93 $apiResponse = HttpHelper::post($apiEndpoint, $requestParams);
94
95 if (is_wp_error($apiResponse) || !empty($apiResponse->error)) {
96 wp_send_json_error(
97 empty($apiResponse->error) ? 'Unknown' : $apiResponse->error,
98 400
99 );
100 }
101 $apiResponse->generates_on = \time();
102 wp_send_json_success($apiResponse, 200);
103 } else {
104 wp_send_json_error(
105 __(
106 'Token expired',
107 'bit-form'
108 ),
109 401
110 );
111 }
112 }
113
114 /**
115 * Process ajax request for refresh bigin modules
116 *
117 * @return JSON bigin module data
118 */
119 public static function refreshModulesAjaxHelper()
120 {
121 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
122 $authorizationHeader = null;
123
124 GlobalHelper::requirePostMethod();
125
126 try {
127 $queryParams = GlobalHelper::formatRequestData();
128 } catch (\InvalidArgumentException $e) {
129 wp_send_json_error($e->getMessage(), 400);
130 }
131
132 if (
133 empty($queryParams->tokenDetails)
134 || empty($queryParams->dataCenter)
135 || empty($queryParams->clientId)
136 || empty($queryParams->clientSecret)
137 ) {
138 wp_send_json_error(
139 __(
140 'Requested parameter is empty',
141 'bit-form'
142 ),
143 400
144 );
145 }
146 $response = [];
147 if ((intval($queryParams->tokenDetails->generates_on) + (55 * 60)) < time()) {
148 $response['tokenDetails'] = ZohoBiginHandler::_refreshAccessToken($queryParams);
149 }
150 $modulesMetaApiEndpoint = "https://www.zohoapis.{$queryParams->dataCenter}/bigin/v1/settings/modules";
151 $authorizationHeader['Authorization'] = "Zoho-oauthtoken {$queryParams->tokenDetails->access_token}";
152 $modulesMetaResponse = HttpHelper::get($modulesMetaApiEndpoint, null, $authorizationHeader);
153 // wp_send_json_success($modulesMetaResponse, 200);
154 if (!is_wp_error($modulesMetaResponse) && (empty($modulesMetaResponse->status) || (!empty($modulesMetaResponse->status) && 'error' !== $modulesMetaResponse->status))) {
155 $retriveModuleData = $modulesMetaResponse->modules;
156 $allModules = [];
157 foreach ($retriveModuleData as $module) {
158 if (!in_array($module->api_name, ['Activities', 'Social', 'Associated_Products', 'Notes', 'Attachments'])) {
159 $allModules[$module->plural_label] = (object) [
160 'api_name' => $module->api_name,
161 'plural_label' => $module->plural_label
162 ];
163 }
164 }
165 uksort($allModules, 'strnatcasecmp');
166 $response['modules'] = $allModules;
167 } else {
168 wp_send_json_error(
169 empty($modulesMetaResponse->error) ? 'Unknown' : $modulesMetaResponse->error,
170 400
171 );
172 }
173 if (!empty($response['tokenDetails']) && !empty($queryParams->id)) {
174 ZohoBiginHandler::_saveRefreshedToken($queryParams->formID, $queryParams->id, $response['tokenDetails'], $response['modules']);
175 }
176 wp_send_json_success($response, 200);
177 } else {
178 wp_send_json_error(
179 __(
180 'Token expired',
181 'bit-form'
182 ),
183 401
184 );
185 }
186 }
187
188 /**
189 * Process ajax request for refresh bigin modules
190 *
191 * @return JSON bigin module data
192 */
193 public static function refreshRelatedModulesAjaxHelper()
194 {
195 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
196 GlobalHelper::requirePostMethod();
197
198 try {
199 $queryParams = GlobalHelper::formatRequestData();
200 } catch (\InvalidArgumentException $e) {
201 wp_send_json_error($e->getMessage(), 400);
202 }
203
204 if (
205 empty($queryParams->tokenDetails)
206 || empty($queryParams->dataCenter)
207 || empty($queryParams->clientId)
208 || empty($queryParams->clientSecret)
209 || empty($queryParams->module)
210 ) {
211 wp_send_json_error(
212 __(
213 'Requested parameter is empty',
214 'bit-form'
215 ),
216 400
217 );
218 }
219 $response = [];
220 $relatedModules = [];
221
222 $allModules = [
223 'Tasks' => (object) [
224 'api_name' => 'Tasks',
225 'plural_label' => 'Tasks'
226 ],
227 'Events' => (object) [
228 'api_name' => 'Events',
229 'plural_label' => 'Events'
230 ],
231 'Calls' => (object) [
232 'api_name' => 'Calls',
233 'plural_label' => 'Calls'
234 ],
235 ];
236 // $modulesMetaApiEndpoint = "https://www.zohoapis.{$queryParams->dataCenter}/bigin/v1/settings/related_lists";
237 // $authorizationHeader["Authorization"] = "Zoho-oauthtoken {$queryParams->tokenDetails->access_token}";
238 // $requiredParams['module'] = $queryParams->module;
239 // $modulesMetaResponse = HttpHelper::get($modulesMetaApiEndpoint, $queryParams, $authorizationHeader);
240 // wp_send_json_success($modulesMetaResponse, 200);
241 foreach ($allModules as $module) {
242 if ($module->api_name !== $queryParams->module) {
243 $relatedModules[$module->plural_label] = (object) [
244 'api_name' => $module->api_name,
245 'plural_label' => $module->plural_label
246 ];
247 }
248 }
249 uksort($relatedModules, 'strnatcasecmp');
250 $response['related_modules'] = $relatedModules;
251
252 if (!empty($response['tokenDetails']) && !empty($queryParams->id)) {
253 ZohoBiginHandler::_saveRefreshedToken($queryParams->formID, $queryParams->id, $response['tokenDetails'], $response['related_modules']);
254 }
255 wp_send_json_success($response, 200);
256 } else {
257 wp_send_json_error(
258 __(
259 'Token expired',
260 'bit-form'
261 ),
262 401
263 );
264 }
265 }
266
267 /**
268 * Process ajax request for refesh bigin layouts
269 *
270 * @return JSON bigin layout data
271 */
272 public static function getFields()
273 {
274 $authorizationHeader = null;
275 $requiredParams = null;
276 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
277 GlobalHelper::requirePostMethod();
278
279 try {
280 $queryParams = GlobalHelper::formatRequestData();
281 } catch (\InvalidArgumentException $e) {
282 wp_send_json_error($e->getMessage(), 400);
283 }
284
285 if (
286 empty($queryParams->module)
287 || empty($queryParams->tokenDetails)
288 || empty($queryParams->dataCenter)
289 || empty($queryParams->clientId)
290 || empty($queryParams->clientSecret)
291 ) {
292 wp_send_json_error(
293 __(
294 'Requested parameter is empty',
295 'bit-form'
296 ),
297 400
298 );
299 }
300 $response = [];
301 if ((intval($queryParams->tokenDetails->generates_on) + (55 * 60)) < time()) {
302 $response['tokenDetails'] = ZohoBiginHandler::_refreshAccessToken($queryParams);
303 }
304 $fieldsMetaApiEndpoint = "https://www.zohoapis.{$queryParams->dataCenter}/bigin/v1/settings/fields";
305 $authorizationHeader['Authorization'] = "Zoho-oauthtoken {$queryParams->tokenDetails->access_token}";
306 $requiredParams['module'] = $queryParams->module;
307 $fieldsMetaResponse = HttpHelper::get($fieldsMetaApiEndpoint, $requiredParams, $authorizationHeader);
308
309 if (!is_wp_error($fieldsMetaResponse) && (empty($fieldsMetaResponse->status) || (!empty($fieldsMetaResponse->status) && 'error' !== $fieldsMetaResponse->status))) {
310 $retriveFieldsData = $fieldsMetaResponse->fields;
311 $fields = [];
312 $fileUploadFields = [];
313 $requiredFields = [];
314 $requiredFileUploadFiles = [];
315 foreach ($retriveFieldsData as $field) {
316 $fields[$field->api_name] = (object) [
317 'api_name' => $field->api_name,
318 'display_label' => $field->display_label,
319 'data_type' => $field->data_type,
320 'length' => $field->length,
321 'required' => $field->system_mandatory
322 ];
323 if ($field->system_mandatory) {
324 $requiredFields[] = $field->api_name;
325 }
326 }
327
328 $fields['Pipeline'] = (object) [
329 'api_name' => 'Pipeline',
330 'display_label' => 'Pipeline',
331 'data_type' => 'text',
332 'length' => 120,
333 'required' => true
334 ];
335 $requiredFields[] = 'Pipeline';
336
337 uksort($fields, 'strnatcasecmp');
338 uksort($fileUploadFields, 'strnatcasecmp');
339 usort($requiredFields, 'strnatcasecmp');
340 usort($requiredFileUploadFiles, 'strnatcasecmp');
341
342 $fieldDetails = (object) [
343 'fields' => $fields,
344 'fileUploadFields' => $fileUploadFields,
345 'required' => $requiredFields,
346 'requiredFileUploadFields' => $requiredFileUploadFiles
347 ];
348 $response['fieldDetails'] = $fieldDetails;
349 } else {
350 wp_send_json_error(
351 'error' === $fieldsMetaResponse->status ? $fieldsMetaResponse->message : 'Unknown',
352 400
353 );
354 }
355 if (!empty($response['tokenDetails']) && $response['tokenDetails'] && !empty($queryParams->id)) {
356 $response['queryModule'] = $queryParams->module;
357 ZohoBiginHandler::_saveRefreshedToken($queryParams->formID, $queryParams->id, $response['tokenDetails'], $response);
358 }
359 wp_send_json_success($response, 200);
360 } else {
361 wp_send_json_error(
362 __(
363 'Token expired',
364 'bit-form'
365 ),
366 401
367 );
368 }
369 }
370
371 public static function getTagList()
372 {
373 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
374 $authorizationHeader = null;
375
376 GlobalHelper::requirePostMethod();
377
378 try {
379 $queryParams = GlobalHelper::formatRequestData();
380 } catch (\InvalidArgumentException $e) {
381 wp_send_json_error($e->getMessage(), 400);
382 }
383 if (
384 empty($queryParams->tokenDetails)
385 || empty($queryParams->dataCenter)
386 || empty($queryParams->clientId)
387 || empty($queryParams->clientSecret)
388 || empty($queryParams->module)
389 ) {
390 wp_send_json_error(
391 __(
392 'Requested parameter is empty',
393 'bit-form'
394 ),
395 400
396 );
397 }
398
399 $response = [];
400 if ((intval($queryParams->tokenDetails->generates_on) + (55 * 60)) < time()) {
401 $response['tokenDetails'] = ZohoBiginHandler::_refreshAccessToken($queryParams);
402 }
403
404 $tagsMetaApiEndpoint = "https://www.zohoapis.{$queryParams->dataCenter}/bigin/v1/settings/tags?module={$queryParams->module}";
405 $authorizationHeader['Authorization'] = "Zoho-oauthtoken {$queryParams->tokenDetails->access_token}";
406 $tagsMetaResponse = HttpHelper::get($tagsMetaApiEndpoint, null, $authorizationHeader);
407
408 if (!is_wp_error($tagsMetaResponse)) {
409 $tags = $tagsMetaResponse->tags;
410
411 if (count($tags) > 0) {
412 $allTags = [];
413 foreach ($tags as $tag) {
414 $allTags[$tag->name] = (object) [
415 'tagId' => $tag->id,
416 'tagName' => $tag->name
417 ];
418 }
419 uksort($allTags, 'strnatcasecmp');
420 $response['tags'] = $allTags;
421 }
422 } else {
423 wp_send_json_error(
424 empty($tagsMetaResponse->data) ? 'Unknown' : $tagsMetaResponse->error,
425 400
426 );
427 }
428 if (!empty($response['tokenDetails']) && !empty($queryParams->id)) {
429 ZohoBiginHandler::_saveRefreshedToken($queryParams->formID, $queryParams->id, $response['tokenDetails'], $response['lists']);
430 }
431 wp_send_json_success($response, 200);
432 } else {
433 wp_send_json_error(
434 __(
435 'Token expired',
436 'bit-form'
437 ),
438 401
439 );
440 }
441 }
442
443 public static function getUsers()
444 {
445 if (isset($_REQUEST['_ajax_nonce']) && wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST['_ajax_nonce'])), 'bitforms_save')) {
446 $authorizationHeader = null;
447
448 GlobalHelper::requirePostMethod();
449
450 try {
451 $queryParams = GlobalHelper::formatRequestData();
452 } catch (\InvalidArgumentException $e) {
453 wp_send_json_error($e->getMessage(), 400);
454 }
455
456 if (
457 empty($queryParams->tokenDetails)
458 || empty($queryParams->dataCenter)
459 || empty($queryParams->clientId)
460 || empty($queryParams->clientSecret)
461 ) {
462 wp_send_json_error(
463 __(
464 'Requested parameter is empty',
465 'bit-form'
466 ),
467 400
468 );
469 }
470
471 $response = [];
472 if ((intval($queryParams->tokenDetails->generates_on) + (55 * 60)) < time()) {
473 $response['tokenDetails'] = ZohoBiginHandler::_refreshAccessToken($queryParams);
474 }
475
476 $usersMetaApiEndpoint = "https://www.zohoapis.{$queryParams->dataCenter}/bigin/v1/users";
477 $authorizationHeader['Authorization'] = "Zoho-oauthtoken {$queryParams->tokenDetails->access_token}";
478 $usersMetaResponse = HttpHelper::get($usersMetaApiEndpoint, null, $authorizationHeader);
479
480 // wp_send_json_success($usersMetaResponse, 200);
481
482 if (!is_wp_error($usersMetaResponse)) {
483 $users = $usersMetaResponse->users;
484
485 if (count($users) > 0) {
486 $allUsers = [];
487 foreach ($users as $user) {
488 $allUsers[$user->full_name] = (object) [
489 'userId' => $user->id,
490 'userName' => $user->full_name
491 ];
492 }
493 uksort($allUsers, 'strnatcasecmp');
494 $response['users'] = $allUsers;
495 }
496 } else {
497 wp_send_json_error(
498 empty($usersMetaResponse->data) ? 'Unknown' : $usersMetaResponse->error,
499 400
500 );
501 }
502 if (!empty($response['tokenDetails']) && !empty($queryParams->id)) {
503 ZohoBiginHandler::_saveRefreshedToken($queryParams->formID, $queryParams->id, $response['tokenDetails'], $response['lists']);
504 }
505 wp_send_json_success($response, 200);
506 } else {
507 wp_send_json_error(
508 __(
509 'Token expired',
510 'bit-form'
511 ),
512 401
513 );
514 }
515 }
516
517 /**
518 * Helps to refresh zoho bigin access_token
519 *
520 * @param object $apiData Contains required data for refresh access token
521 * @return string|boolean $tokenDetails API token details
522 */
523 protected static function _refreshAccessToken($apiData)
524 {
525 if (
526 empty($apiData->dataCenter)
527 || empty($apiData->clientId)
528 || empty($apiData->clientSecret)
529 || empty($apiData->tokenDetails)
530 ) {
531 return false;
532 }
533 $tokenDetails = $apiData->tokenDetails;
534
535 $dataCenter = $apiData->dataCenter;
536 $apiEndpoint = "https://accounts.zoho.{$dataCenter}/oauth/v2/token";
537 $requestParams = [
538 'grant_type' => 'refresh_token',
539 'client_id' => $apiData->clientId,
540 'client_secret' => $apiData->clientSecret,
541 'refresh_token' => $tokenDetails->refresh_token,
542 ];
543
544 $apiResponse = HttpHelper::post($apiEndpoint, $requestParams);
545 if (is_wp_error($apiResponse) || !empty($apiResponse->error)) {
546 return false;
547 }
548 $tokenDetails->generates_on = \time();
549 $tokenDetails->access_token = $apiResponse->access_token;
550 return $tokenDetails;
551 }
552
553 /**
554 * Save updated access_token to avoid unnecessary token generation
555 *
556 * @param integer $fromID ID of Integration related form
557 * @param integer $integrationID ID of Zoho bigin Integration
558 * @param object $tokenDetails refreshed token info
559 *
560 * @return null
561 */
562 protected static function _saveRefreshedToken($formID, $integrationID, $tokenDetails, $others = null)
563 {
564 if (empty($formID) || empty($integrationID)) {
565 return;
566 }
567
568 $integrationHandler = new IntegrationHandler($formID, IpTool::getUserDetail());
569 $zbiginDetails = $integrationHandler->getAIntegration($integrationID);
570
571 if (is_wp_error($zbiginDetails)) {
572 return;
573 }
574 $newDetails = json_decode($zbiginDetails[0]->integration_details);
575
576 $newDetails->tokenDetails = $tokenDetails;
577 if (!empty($others['modules'])) {
578 $newDetails->default->modules = $others['modules'];
579 }
580 if (!empty($others['related_modules'])) {
581 $newDetails->default->relatedlist['modules'] = $others['related_modules'];
582 }
583
584 $integrationHandler->updateIntegration($integrationID, $zbiginDetails[0]->integration_name, 'Zoho Bigin', wp_json_encode($newDetails), 'form');
585 }
586
587 public function execute(IntegrationHandler $integrationHandler, $integrationData, $fieldValues, $entryID, $logID)
588 {
589 $integrationDetails = is_string($integrationData->integration_details) ? json_decode($integrationData->integration_details) : $integrationData->integration_details;
590 $integID = $integrationData->id;
591 $tokenDetails = $integrationDetails->tokenDetails;
592 $module = $integrationDetails->module;
593 $fieldMap = $integrationDetails->field_map;
594 $actions = $integrationDetails->actions;
595 $defaultDataConf = $integrationDetails->default;
596
597 $entryDetails = [
598 'formId' => $this->_formID,
599 'entryId' => $entryID,
600 'fieldValues' => $fieldValues
601 ];
602 if (
603 empty($tokenDetails)
604 || empty($module)
605 || empty($fieldMap)
606 ) {
607 $error = new WP_Error('REQ_FIELD_EMPTY', __('module, fields are required for zoho bigin api', 'bit-form'));
608 $this->_logResponse->apiResponse($logID, $this->_integrationID, 'record', 'validation', $error, $entryDetails);
609 return $error;
610 }
611 $requiredParams = null;
612 if ((intval($tokenDetails->generates_on) + (55 * 60)) < time()) {
613 $requiredParams['clientId'] = $integrationDetails->clientId;
614 $requiredParams['clientSecret'] = $integrationDetails->clientSecret;
615 $requiredParams['dataCenter'] = $integrationDetails->dataCenter;
616 $requiredParams['tokenDetails'] = $tokenDetails;
617 $newTokenDetails = ZohoBiginHandler::_refreshAccessToken((object)$requiredParams);
618 if ($newTokenDetails) {
619 ZohoBiginHandler::_saveRefreshedToken($this->_formID, $this->_integrationID, $newTokenDetails);
620 $tokenDetails = $newTokenDetails;
621 }
622 }
623
624 $required = !empty($defaultDataConf->moduleData->{$module}->required) ?
625 $defaultDataConf->moduleData->{$module}->required : [];
626
627 $actions = $integrationDetails->actions;
628 $fileMap = $integrationDetails->upload_field_map;
629 $recordApiHelper = new RecordApiHelper($tokenDetails, $integID, $logID);
630 $zBiginApiResponse = $recordApiHelper->executeRecordApi(
631 $this->_formID,
632 $entryID,
633 $defaultDataConf,
634 $module,
635 $fieldValues,
636 $fieldMap,
637 $actions,
638 $required,
639 $fileMap
640 );
641 if (is_wp_error($zBiginApiResponse)) {
642 return $zBiginApiResponse;
643 }
644
645 if (
646 count($integrationDetails->relatedlists)
647 && !empty($zBiginApiResponse->response->result->row->success->details->FL[0])
648 && 'Id' === $zBiginApiResponse->response->result->row->success->details->FL[0]->val
649 ) {
650 foreach ($integrationDetails->relatedlists as $relatedlist) {
651 if (!empty($relatedlist->module)) {
652 $recordID = $zBiginApiResponse->response->result->row->success->details->FL[0]->content;
653 $relatedListModule = $relatedlist->module;
654 $defaultDataConf->moduleData->{$relatedListModule}->fields->{'SEMODULE'} = (object) [
655 'length' => \strlen($relatedListModule),
656 'required' => true,
657 'data_type' => 'string',
658 ];
659 $fieldValues['SEMODULE'] = $relatedListModule;
660 $relatedlist->field_map[] = (object)
661 [
662 'formField' => 'SEMODULE',
663 'zohoFormField' => 'SEMODULE'
664 ];
665
666 $defaultDataConf->moduleData->{$relatedListModule}->fields->{'SEID'} = (object) [
667 'length' => \strlen($recordID),
668 'required' => true,
669 'data_type' => 'string',
670 ];
671 $fieldValues['SEID'] = $recordID;
672 $relatedlist->field_map[] = (object)
673 [
674 'formField' => 'SEID',
675 'zohoFormField' => 'SEID'
676 ];
677
678 $zBiginRelatedRecResp = $recordApiHelper->executeRecordApi(
679 $this->_formID,
680 $entryID,
681 $defaultDataConf,
682 $relatedListModule,
683 $fieldValues,
684 $relatedlist->field_map,
685 $relatedlist->actions,
686 !empty($defaultDataConf->moduleData->{$relatedListModule}->required) ?
687 $defaultDataConf->moduleData->{$relatedListModule}->required : [],
688 $relatedlist->upload_field_map
689 );
690 }
691 }
692 }
693 return $zBiginApiResponse;
694 }
695 }
696