From 52382473dad5356977343c5f450c5f766dfa8b4c Mon Sep 17 00:00:00 2001 From: Meteo Date: Wed, 7 Jan 2026 23:18:14 +0100 Subject: [PATCH] moved some of the inserve api enpoints to different places --- pub/api/v1/permissions/index.php | 2 +- pub/api/v1/sources/inserve/index.php | 4 +-- .../sources/inserve/subscriptions/index.php | 32 ------------------- .../inserve/sync-cloud-distributor/index.php | 22 +++++++++++++ .../inserve/sync-companies}/index.php | 3 +- .../inserve/sync-server-licenses/index.php | 20 ++++++++++++ 6 files changed, 45 insertions(+), 38 deletions(-) delete mode 100644 pub/api/v1/sources/inserve/subscriptions/index.php create mode 100644 pub/api/v1/sources/inserve/sync-cloud-distributor/index.php rename pub/api/v1/{customers/companies/sync => sources/inserve/sync-companies}/index.php (95%) create mode 100644 pub/api/v1/sources/inserve/sync-server-licenses/index.php diff --git a/pub/api/v1/permissions/index.php b/pub/api/v1/permissions/index.php index 906d34a..27c9de8 100644 --- a/pub/api/v1/permissions/index.php +++ b/pub/api/v1/permissions/index.php @@ -25,7 +25,7 @@ if ($API_permissions->request_method === 'GET') { $API_permissions->validateData($requiredFields, $optionalFields); $permissions = $API_permissions->getPermission(); - $API_permissions->apiOutput($code = 200, ['success' => $permissions], 'permission_created'); + $API_permissions->apiOutput($code = 200, ['success' => $permissions], 'permission_retrieved'); } elseif ($API_permissions->request_method === 'POST') { diff --git a/pub/api/v1/sources/inserve/index.php b/pub/api/v1/sources/inserve/index.php index 9c63434..26c9a2e 100644 --- a/pub/api/v1/sources/inserve/index.php +++ b/pub/api/v1/sources/inserve/index.php @@ -13,6 +13,7 @@ $API_inserve->setupConnection(); if ($API_inserve->request_method === 'GET') { if ($_GET['action'] = 'auth/me') { + $API_inserve->checkPermissions('admin-sources', 'RO'); # This api call, when called from the frontend will not be forwarding to a url. $API_inserve->return_url = false; @@ -21,6 +22,3 @@ if ($API_inserve->request_method === 'GET') { http_response_code($API_inserve->httpCode); } } - - - diff --git a/pub/api/v1/sources/inserve/subscriptions/index.php b/pub/api/v1/sources/inserve/subscriptions/index.php deleted file mode 100644 index deeb939..0000000 --- a/pub/api/v1/sources/inserve/subscriptions/index.php +++ /dev/null @@ -1,32 +0,0 @@ -request_method === 'GET') { - - if ($_GET['action'] == 'sync-companies') { - # This syncs the company id's from Sentri to the Inserve cloudDistributor - # These are the same id's but it Inserve requires it to be synced to the cloudDistributor - $API_inserve->checkPermissions('servers', 'RW'); - $API_inserve->setupConnection(); - - $API_inserve->syncCompaniesFromSentri(); - - } - - - if ($_GET['action'] == 'sync-subscriptions') { - $API_inserve->checkPermissions('servers', 'RW'); - $API_inserve->setupConnection(); - - $API_inserve->syncServerLicencesToInserve(); - - } -} \ No newline at end of file diff --git a/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php b/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php new file mode 100644 index 0000000..5370d16 --- /dev/null +++ b/pub/api/v1/sources/inserve/sync-cloud-distributor/index.php @@ -0,0 +1,22 @@ +request_method === 'GET' || $API_inserve->request_method === 'POST') { + # This syncs the company id's from Sentri to the Inserve cloudDistributor + # These are the same id's but it Inserve requires it to be synced to the cloudDistributor + $API_inserve->checkPermissions('servers', 'RW'); + $API_inserve->setupConnection(); + + $API_inserve->syncCompaniesFromSentri(); + + + $API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']); +} \ No newline at end of file diff --git a/pub/api/v1/customers/companies/sync/index.php b/pub/api/v1/sources/inserve/sync-companies/index.php similarity index 95% rename from pub/api/v1/customers/companies/sync/index.php rename to pub/api/v1/sources/inserve/sync-companies/index.php index 7a3feae..295f0bd 100644 --- a/pub/api/v1/customers/companies/sync/index.php +++ b/pub/api/v1/sources/inserve/sync-companies/index.php @@ -9,9 +9,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php'; $API_inserve = new API_inserve(); $API_inserve->setupConnection(); -if ($API_inserve->request_method === 'POST') { +if ($API_inserve->request_method === 'POST' || $API_inserve->request_method === 'GET') { # Code below will retrieve all the companies and create or update it in the database - # $API_inserve->checkPermissions('customer-companies', 'RW'); diff --git a/pub/api/v1/sources/inserve/sync-server-licenses/index.php b/pub/api/v1/sources/inserve/sync-server-licenses/index.php new file mode 100644 index 0000000..2d37935 --- /dev/null +++ b/pub/api/v1/sources/inserve/sync-server-licenses/index.php @@ -0,0 +1,20 @@ +request_method === 'GET' || $API_inserve->request_method === 'POST') { + $API_inserve->checkPermissions('servers', 'RW'); + $API_inserve->setupConnection(); + + $API_inserve->syncCompaniesFromSentri(); + $API_inserve->syncServerLicencesToInserve(); + + $API_inserve->apiOutput(200, ['success' => 'Sync is done successfully']); +} \ No newline at end of file