Small code fixes in API code
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace api\classes;
|
||||
|
||||
use api\classes\API;
|
||||
use JetBrains\PhpStorm\NoReturn;
|
||||
|
||||
require_once 'API.php';
|
||||
|
||||
@@ -44,11 +45,6 @@ class API_inserve extends API
|
||||
curl_close($this->ch);
|
||||
}
|
||||
|
||||
public function returnResponse()
|
||||
{
|
||||
$this->apiOutput($this->httpCode, json_decode($this->response, true));
|
||||
}
|
||||
|
||||
public function authMe()
|
||||
{
|
||||
$this->ch = curl_init($this->inserve_url . 'auth/me');
|
||||
@@ -60,6 +56,7 @@ class API_inserve extends API
|
||||
]
|
||||
]);
|
||||
$this->execCurl();
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getLinkedCompanies()
|
||||
@@ -246,7 +243,7 @@ class API_inserve extends API
|
||||
];
|
||||
|
||||
if (!in_array($type, $allowedColumns, true)) {
|
||||
throw new Exception('Invalid column name');
|
||||
throw new \RuntimeException('Invalid column name');
|
||||
}
|
||||
|
||||
$query = "SELECT `$type` FROM servers";
|
||||
@@ -256,7 +253,7 @@ class API_inserve extends API
|
||||
|
||||
$servers = [];
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
array_push($servers, $row);
|
||||
$servers[] = $row;
|
||||
}
|
||||
|
||||
$allTypes = [];
|
||||
@@ -451,7 +448,7 @@ class API_inserve extends API
|
||||
$namePart = substr($key, 7, -6);
|
||||
$namePart = ucfirst($namePart);
|
||||
} // Handle keys with "."
|
||||
elseif (strpos($key, '.') !== false) {
|
||||
elseif (str_contains($key, '.')) {
|
||||
[$first, $second] = explode('.', $key, 2);
|
||||
if ($first === $second || strtolower($second) === 'yes') {
|
||||
$namePart = ucfirst($first);
|
||||
@@ -459,7 +456,7 @@ class API_inserve extends API
|
||||
$namePart = ucfirst($first) . ' - ' . $second;
|
||||
}
|
||||
} //Handle keys without . but with a space (example directadmin.Standard Discounted)
|
||||
elseif (strpos($key, ' ') !== false) {
|
||||
elseif (str_contains($key, ' ')) {
|
||||
// explode on first .
|
||||
$parts = explode('.', $key, 2);
|
||||
if (count($parts) === 2) {
|
||||
@@ -513,16 +510,14 @@ class API_inserve extends API
|
||||
&& $item['subscriptionInserveExists'] !== false
|
||||
) {
|
||||
$payload = [
|
||||
"quantity" => (int)$item['countSentri'],
|
||||
"quantity" => ($row['server_state'] === 'deleted') ? 0 : $item['countSentri'],
|
||||
"cloud_distribution_company_id" => (int)$item['sentriCompanyId'],
|
||||
"name" => $item['subscriptionSentriName'],
|
||||
"status" => $item['SentriStatus'],
|
||||
"quantity" => ($row['server_state'] === 'deleted') ? 0 : $item['countSentri']
|
||||
"status" => $item['SentriStatus']
|
||||
];
|
||||
|
||||
$this->updateCloudSubscription($item['subscriptionInserveId'], $payload);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user