| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') || exit; |
| 4 |
|
| 5 |
/** |
| 6 |
* REST API route definitions. |
| 7 |
*/ |
| 8 |
|
| 9 |
/* |
| 10 |
* Forms resource |
| 11 |
*/ |
| 12 |
/** |
| 13 |
* Router supplied by the framework's route loader. |
| 14 |
* |
| 15 |
* @var \FluentForm\Framework\Http\Router $router |
| 16 |
*/ |
| 17 |
$router->prefix('forms')->withPolicy('FormPolicy')->group(function ($router) { |
| 18 |
$router->get('/', 'FormController@index'); |
| 19 |
$router->post('/', 'FormController@store'); |
| 20 |
$router->get('templates', 'FormController@templates'); |
| 21 |
$router->get('ping', 'FormController@ping'); |
| 22 |
|
| 23 |
$router->prefix('{form_id}')->group(function ($router) { |
| 24 |
$router->get('/', 'FormController@find'); |
| 25 |
$router->post('/', 'FormController@update'); |
| 26 |
$router->delete('/', 'FormController@delete'); |
| 27 |
$router->post('duplicate', 'FormController@duplicate'); |
| 28 |
$router->post('convert', 'FormController@convert'); |
| 29 |
$router->get('resources', 'FormController@resources'); |
| 30 |
$router->get('pages', 'FormController@pages'); |
| 31 |
$router->get('fields', 'FormController@fields'); |
| 32 |
$router->get('shortcodes', 'FormController@shortcodes'); |
| 33 |
$router->get('findShortCodePage', 'FormController@findShortCodePage'); |
| 34 |
$router->get('editHistory', 'FormController@formEditHistory'); |
| 35 |
$router->post('clearHistory', 'FormController@clearEditHistory'); |
| 36 |
}); |
| 37 |
}); |
| 38 |
|
| 39 |
/* |
| 40 |
* Form Settings |
| 41 |
*/ |
| 42 |
$router->prefix('settings')->withPolicy('FormPolicy')->group(function ($router) { |
| 43 |
$router->prefix('{form_id}')->group(function ($router) { |
| 44 |
$router->get('/', 'FormSettingsController@index'); |
| 45 |
$router->post('/', 'FormSettingsController@store'); |
| 46 |
$router->delete('/', 'FormSettingsController@remove'); |
| 47 |
|
| 48 |
$router->get('general', 'FormSettingsController@general'); |
| 49 |
$router->post('general', 'FormSettingsController@saveGeneral'); |
| 50 |
|
| 51 |
$router->get('customizer', 'FormSettingsController@customizer'); |
| 52 |
$router->post('customizer', 'FormSettingsController@storeCustomizer'); |
| 53 |
|
| 54 |
$router->post('entry-columns', 'FormSettingsController@storeEntryColumns'); |
| 55 |
|
| 56 |
$router->get('conversational-design', 'FormSettingsController@conversationalDesign'); |
| 57 |
$router->post('store-conversational-design', 'FormSettingsController@storeConversationalDesign'); |
| 58 |
$router->get('preset', 'FormSettingsController@getPreset'); |
| 59 |
$router->post('save-preset', 'FormSettingsController@savePreset'); |
| 60 |
}); |
| 61 |
}); |
| 62 |
/* |
| 63 |
* Form Submissions |
| 64 |
*/ |
| 65 |
$router->prefix('submissions')->withPolicy('SubmissionPolicy')->group(function ($router) { |
| 66 |
$router->get('/', 'SubmissionController@index'); |
| 67 |
$router->get('resources', 'SubmissionController@resources'); |
| 68 |
$router->post('bulk-actions', 'SubmissionController@handleBulkActions'); |
| 69 |
$router->get('print', 'SubmissionController@print'); |
| 70 |
$router->get('all', 'SubmissionController@all'); |
| 71 |
$router->delete('/{entry_id}', 'SubmissionController@remove'); |
| 72 |
|
| 73 |
$router->prefix('{entry_id}')->group(function ($router) { |
| 74 |
$router->get('/', 'SubmissionController@find'); |
| 75 |
|
| 76 |
$router->post('status', 'SubmissionController@updateStatus'); |
| 77 |
$router->post('is-favorite', 'SubmissionController@toggleIsFavorite'); |
| 78 |
|
| 79 |
$router->get('logs', 'SubmissionLogController@get'); |
| 80 |
$router->delete('logs', 'SubmissionLogController@remove'); |
| 81 |
|
| 82 |
$router->get('notes', 'SubmissionNoteController@get'); |
| 83 |
$router->post('notes', 'SubmissionNoteController@store'); |
| 84 |
|
| 85 |
$router->get('submission-users', 'SubmissionController@submissionUsers'); |
| 86 |
$router->post('update-submission-user', 'SubmissionController@updateSubmissionUser'); |
| 87 |
}); |
| 88 |
}); |
| 89 |
|
| 90 |
/* |
| 91 |
* Logs |
| 92 |
*/ |
| 93 |
$router->prefix('logs')->withPolicy('SubmissionPolicy')->group(function ($router) { |
| 94 |
$router->get('/', 'LogController@get'); |
| 95 |
$router->delete('/', 'LogController@remove'); |
| 96 |
$router->get('/filters', 'LogController@getFilters'); |
| 97 |
}); |
| 98 |
/* |
| 99 |
* Global Integrations |
| 100 |
*/ |
| 101 |
$router->prefix('integrations')->group(function ($router) { |
| 102 |
$router->get('/', 'GlobalIntegrationController@index')->withPolicy('GlobalIntegrationPolicy'); |
| 103 |
$router->post('/', 'GlobalIntegrationController@updateIntegration')->withPolicy('GlobalIntegrationPolicy'); |
| 104 |
$router->post('update-status', 'GlobalIntegrationController@updateModuleStatus')->withPolicy('GlobalIntegrationPolicy'); |
| 105 |
|
| 106 |
/* |
| 107 |
* Form Integrations |
| 108 |
*/ |
| 109 |
$router->prefix('{form_id}')->withPolicy('FormPolicy')->group(function ($router) { |
| 110 |
$router->get('/form-integrations', 'FormIntegrationController@index'); |
| 111 |
$router->get('/', 'FormIntegrationController@find'); |
| 112 |
$router->post('/', 'FormIntegrationController@update'); |
| 113 |
$router->delete('/', 'FormIntegrationController@delete'); |
| 114 |
|
| 115 |
$router->get('/integration-list-id', 'FormIntegrationController@integrationListComponent'); |
| 116 |
}); |
| 117 |
}); |
| 118 |
/* |
| 119 |
* Global Settings |
| 120 |
*/ |
| 121 |
$router->prefix('global-settings')->withPolicy('GlobalSettingsPolicy')->group(function ($router) { |
| 122 |
$router->get('/', 'GlobalSettingsController@index'); |
| 123 |
$router->post('/', 'GlobalSettingsController@store'); |
| 124 |
}); |
| 125 |
/* |
| 126 |
* MCP (Model Context Protocol) Settings |
| 127 |
*/ |
| 128 |
$router->prefix('mcp')->withPolicy('GlobalSettingsPolicy')->group(function ($router) { |
| 129 |
$router->get('status', 'McpSettingsController@status'); |
| 130 |
$router->post('toggle', 'McpSettingsController@toggle'); |
| 131 |
$router->post('install-adapter', 'McpSettingsController@installAdapter'); |
| 132 |
$router->get('config-snippets', 'McpSettingsController@getConfigSnippets'); |
| 133 |
}); |
| 134 |
/* |
| 135 |
* Permission Roles |
| 136 |
*/ |
| 137 |
$router->prefix('roles')->withPolicy('RoleManagerPolicy')->group(function ($router) { |
| 138 |
$router->get('/', 'RolesController@index'); |
| 139 |
$router->post('/', 'RolesController@addCapability'); |
| 140 |
}); |
| 141 |
/* |
| 142 |
* Permission Managers |
| 143 |
*/ |
| 144 |
$router->prefix('managers')->withPolicy('RoleManagerPolicy')->group(function ($router) { |
| 145 |
$router->get('/', 'ManagersController@index'); |
| 146 |
$router->post('/', 'ManagersController@addManager'); |
| 147 |
$router->delete('/', 'ManagersController@removeManager'); |
| 148 |
$router->get('users', 'ManagersController@getUsers'); |
| 149 |
}); |
| 150 |
|
| 151 |
|
| 152 |
/* |
| 153 |
* Form Analytics |
| 154 |
*/ |
| 155 |
$router->prefix('analytics')->withPolicy('FormPolicy')->group(function ($router) { |
| 156 |
$router->post('/{form_id}/reset', 'AnalyticsController@reset'); |
| 157 |
}); |
| 158 |
|
| 159 |
/* |
| 160 |
* Form Submission Handler |
| 161 |
*/ |
| 162 |
$router->post('form-submit', 'SubmissionHandlerController@submit')->withPolicy('SubmissionPolicy'); |
| 163 |
/* |
| 164 |
* Form Report |
| 165 |
*/ |
| 166 |
$router->prefix('report')->withPolicy('ReportPolicy')->group(function ($router) { |
| 167 |
// Component-specific endpoints |
| 168 |
$router->get('/overview-chart', 'ReportController@getOverviewChart'); |
| 169 |
$router->get('/revenue-chart', 'ReportController@getRevenueChart'); |
| 170 |
$router->get('/completion-rate', 'ReportController@getCompletionRate'); |
| 171 |
$router->get('/form-stats', 'ReportController@getFormStats'); |
| 172 |
$router->get('/heatmap-data', 'ReportController@getHeatmapData'); |
| 173 |
$router->get('/country-heatmap', 'ReportController@getCountryHeatmap'); |
| 174 |
$router->get('/api-logs', 'ReportController@getApiLogs'); |
| 175 |
$router->get('/top-performing-forms', 'ReportController@getTopPerformingForms'); |
| 176 |
$router->get('/subscriptions', 'ReportController@getSubscriptions'); |
| 177 |
$router->get('/payment-types', 'ReportController@getPaymentTypes'); |
| 178 |
|
| 179 |
// Existing endpoints |
| 180 |
$router->get('/select-forms', 'ReportController@getFormsDropdown'); |
| 181 |
$router->get('/net-revenue', 'ReportController@netRevenue'); |
| 182 |
$router->get('/submissions-analysis', 'ReportController@submissionsAnalysis'); |
| 183 |
$router->post('/submissions', 'ReportController@submissions'); |
| 184 |
$router->get('/forms/{form_id}', 'ReportController@form'); |
| 185 |
}); |
| 186 |
/* |
| 187 |
* Review Query |
| 188 |
*/ |
| 189 |
$router->post('notice', 'AdminNoticeController@noticeActions')->withPolicy('FormPolicy'); |
| 190 |
|
| 191 |
/* |
| 192 |
* Global Query |
| 193 |
*/ |
| 194 |
$router->get('global-search', 'GlobalSearchController@index')->withPolicy('FormPolicy'); |
| 195 |
|
| 196 |
/* |
| 197 |
* Suggested Plugins |
| 198 |
*/ |
| 199 |
$router->prefix('suggested-plugins')->withPolicy('FormPolicy')->group(function ($router) { |
| 200 |
$router->post('check-plugin-statuses', 'SuggestedPluginsController@checkPluginStatuses'); |
| 201 |
$router->post('install-plugin', 'SuggestedPluginsController@installPlugin'); |
| 202 |
$router->post('activate-plugin', 'SuggestedPluginsController@activatePlugin'); |
| 203 |
}); |
| 204 |
|