moved some of the inserve api enpoints to different places

This commit is contained in:
2026-01-07 23:18:14 +01:00
parent eb2e4678eb
commit 52382473da
6 changed files with 45 additions and 38 deletions

View File

@@ -25,7 +25,7 @@ if ($API_permissions->request_method === 'GET') {
$API_permissions->validateData($requiredFields, $optionalFields); $API_permissions->validateData($requiredFields, $optionalFields);
$permissions = $API_permissions->getPermission(); $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') { } elseif ($API_permissions->request_method === 'POST') {

View File

@@ -13,6 +13,7 @@ $API_inserve->setupConnection();
if ($API_inserve->request_method === 'GET') { if ($API_inserve->request_method === 'GET') {
if ($_GET['action'] = 'auth/me') { 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. # This api call, when called from the frontend will not be forwarding to a url.
$API_inserve->return_url = false; $API_inserve->return_url = false;
@@ -21,6 +22,3 @@ if ($API_inserve->request_method === 'GET') {
http_response_code($API_inserve->httpCode); http_response_code($API_inserve->httpCode);
} }
} }

View File

@@ -1,32 +0,0 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->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();
}
}

View File

@@ -0,0 +1,22 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->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']);
}

View File

@@ -9,9 +9,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve(); $API_inserve = new API_inserve();
$API_inserve->setupConnection(); $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 # Code below will retrieve all the companies and create or update it in the database
#
$API_inserve->checkPermissions('customer-companies', 'RW'); $API_inserve->checkPermissions('customer-companies', 'RW');

View File

@@ -0,0 +1,20 @@
<?php
use api\classes\API_inserve;
session_start();
require_once $_SERVER['DOCUMENT_ROOT'] . '/api/classes/API_inserve.php';
$API_inserve = new API_inserve();
if ($API_inserve->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']);
}