| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\App\Http\Controllers; |
| 4 |
|
| 5 |
use FluentForm\App\Services\Integrations\FormIntegrationService; |
| 6 |
|
| 7 |
class FormIntegrationController extends Controller |
| 8 |
{ |
| 9 |
public function index(FormIntegrationService $integrationService) |
| 10 |
{ |
| 11 |
try { |
| 12 |
$formId = (int) $this->request->get('form_id'); |
| 13 |
return $this->sendSuccess( |
| 14 |
$integrationService->get($formId) |
| 15 |
); |
| 16 |
} catch (\Exception $e) { |
| 17 |
return $this->sendError([ |
| 18 |
'message' => $e->getMessage(), |
| 19 |
], 422); |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
public function find(FormIntegrationService $integrationService) |
| 24 |
{ |
| 25 |
try { |
| 26 |
$integration = $integrationService->find($this->request->all()); |
| 27 |
return $this->sendSuccess($integration); |
| 28 |
} catch (Exception $e) { |
| 29 |
return $this->sendError([ |
| 30 |
'message' => $e->getMessage(), |
| 31 |
], 422); |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
public function update(FormIntegrationService $integrationService) |
| 36 |
{ |
| 37 |
try { |
| 38 |
$integration = $integrationService->update($this->request->all()); |
| 39 |
return $this->sendSuccess($integration); |
| 40 |
} catch (Exception $e) { |
| 41 |
return $this->sendError([ |
| 42 |
'message' => $e->getMessage() |
| 43 |
], 422); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public function delete(FormIntegrationService $integrationService) |
| 48 |
{ |
| 49 |
try { |
| 50 |
$id = $this->request->get('integration_id'); |
| 51 |
$integrationService->delete($id); |
| 52 |
return $this->sendSuccess([ |
| 53 |
'message' => __('Successfully deleted the Integration.', 'fluentform'), |
| 54 |
], 200); |
| 55 |
} catch (Exception $e) { |
| 56 |
return $this->sendError([ |
| 57 |
'message' => $e->getMessage(), |
| 58 |
], 422); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
public function integrationListComponent() |
| 63 |
{ |
| 64 |
try { |
| 65 |
$integrationName = $this->request->get('integration_name'); |
| 66 |
$formId = intval($this->request->get('form_id')); |
| 67 |
$listId = $this->request->get('list_id'); |
| 68 |
$merge_fields = false; |
| 69 |
$merge_fields = apply_filters_deprecated( |
| 70 |
'fluentform_get_integration_merge_fields_' . $integrationName, |
| 71 |
[ |
| 72 |
$merge_fields, |
| 73 |
$listId, |
| 74 |
$formId |
| 75 |
], |
| 76 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 77 |
'fluentform/get_integration_merge_fields_' . $integrationName, |
| 78 |
'Use fluentform/get_integration_merge_fields_' . $integrationName . ' instead of fluentform_get_integration_merge_fields_' . $integrationName |
| 79 |
); |
| 80 |
|
| 81 |
$merge_fields = apply_filters('fluentform/get_integration_merge_fields_' . $integrationName, $merge_fields, $listId, $formId); |
| 82 |
|
| 83 |
return $this->sendSuccess([ |
| 84 |
'merge_fields' => $merge_fields, |
| 85 |
]); |
| 86 |
} catch (Exception $e) { |
| 87 |
return $this->sendError([ |
| 88 |
'message' => $e->getMessage(), |
| 89 |
], 422); |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
} |
| 94 |
|