Typos in API code fixed
This commit is contained in:
@@ -23,7 +23,7 @@ class API_inserve extends API
|
||||
|
||||
public $response = false;
|
||||
|
||||
private $cloudDistrubutor = false;
|
||||
private $cloudDistributor = false;
|
||||
|
||||
public function setupConnection()
|
||||
{
|
||||
@@ -64,14 +64,14 @@ class API_inserve extends API
|
||||
|
||||
public function getLinkedCompanies()
|
||||
{
|
||||
# init the clouddistrubutor name
|
||||
if (!isset($this->inserve_custom_data['clouddistrubutor']) || $this->inserve_custom_data['clouddistrubutor'] === '') {
|
||||
$this->apiOutput(400, ['error' => 'missing clouddistrubutor in custom source data']);
|
||||
# init the cloudDistributor name
|
||||
if (!isset($this->inserve_custom_data['cloudDistributor']) || $this->inserve_custom_data['cloudDistributor'] === '') {
|
||||
$this->apiOutput(400, ['error' => 'missing cloudDistributor in custom source data']);
|
||||
} else {
|
||||
$this->cloudDistrubutor = $this->inserve_custom_data['clouddistrubutor'];
|
||||
$this->cloudDistributor = $this->inserve_custom_data['cloudDistributor'];
|
||||
}
|
||||
|
||||
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/' . $this->cloudDistrubutor . '/companies');
|
||||
$this->ch = curl_init($this->inserve_url . 'cloud-distributors/' . $this->cloudDistributor . '/companies');
|
||||
curl_setopt_array($this->ch, [
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_HTTPHEADER => [
|
||||
@@ -128,11 +128,11 @@ class API_inserve extends API
|
||||
|
||||
public function syncCompaniesFromSentri()
|
||||
{
|
||||
# init the clouddistrubutor name
|
||||
if (!isset($this->inserve_custom_data['clouddistrubutor']) || $this->inserve_custom_data['clouddistrubutor'] === '') {
|
||||
$this->apiOutput(400, ['error' => 'missing clouddistrubutor in custom source data']);
|
||||
# init the cloudDistributor name
|
||||
if (!isset($this->inserve_custom_data['cloudDistributor']) || $this->inserve_custom_data['cloudDistributor'] === '') {
|
||||
$this->apiOutput(400, ['error' => 'missing cloudDistributor in custom source data']);
|
||||
} else {
|
||||
$this->cloudDistrubutor = $this->inserve_custom_data['clouddistrubutor'];
|
||||
$this->cloudDistributor = $this->inserve_custom_data['cloudDistributor'];
|
||||
}
|
||||
|
||||
# First retrieve all the active companies to sync to the Inserve cloud distributor
|
||||
@@ -148,7 +148,7 @@ class API_inserve extends API
|
||||
];
|
||||
}
|
||||
|
||||
$url = $this->inserve_url . 'cloud-distributors/' . $this->cloudDistrubutor . '/companies';
|
||||
$url = $this->inserve_url . 'cloud-distributors/' . $this->cloudDistributor . '/companies';
|
||||
|
||||
$this->ch = curl_init($url);
|
||||
|
||||
@@ -430,7 +430,7 @@ class API_inserve extends API
|
||||
$item['subscriptionInserveCompanyId'] = $inserveLookup[$item['md5']]['cloud_distribution_company_id'];
|
||||
$item['subscriptionInserveName'] = $inserveLookup[$item['md5']]['name'];
|
||||
//$item['subscriptionInserveStatus'] = $inserveLookup[$item['md5']]['status'];
|
||||
} else { # Subscription does not exists in Inserve
|
||||
} else { # Subscription does not exist in Inserve
|
||||
$item['sentriCompanyId'] = (int)$allCompaniesIds[$row['company_source_id']] ?? 0;
|
||||
$item['subscriptionInserveExists'] = false;
|
||||
$item['subscriptionInserveId'] = false;
|
||||
@@ -458,7 +458,7 @@ class API_inserve extends API
|
||||
} else {
|
||||
$namePart = ucfirst($first) . ' - ' . $second;
|
||||
}
|
||||
} //Handle keys without . but with a space (expmale directadmin.Standard Discounted)
|
||||
} //Handle keys without . but with a space (example directadmin.Standard Discounted)
|
||||
elseif (strpos($key, ' ') !== false) {
|
||||
// explode on first .
|
||||
$parts = explode('.', $key, 2);
|
||||
@@ -487,13 +487,13 @@ class API_inserve extends API
|
||||
// if subscriptionInserveExists is false create a new subscription
|
||||
if ($item['subscriptionInserveExists'] === false) {
|
||||
$payload = [
|
||||
"cloud_distribution_id" => $item['md5'], #md5 hash based on the server_uuid from sentri and the subscription name (eg. server_cpu_count)
|
||||
"cloud_distribution_id" => $item['md5'], #md5 hash based on the server_uuid from sentri and the subscription name (e.g. server_cpu_count)
|
||||
"cloud_subscription_id" => "sentri-servers", # Mark all the sentri-servers subscriptions so we can filter the subscriptions better
|
||||
"name" => $item['subscriptionSentriName'],
|
||||
"quantity" => ($row['server_state'] === 'deleted') ? 0 : $item['countSentri'],
|
||||
"cloud_distribution_company_id" => $item['sentriCompanyId'], # this is generated by inserve
|
||||
"status" => $item['SentriStatus'],
|
||||
"period_type" => 0, # 0 = monthly, 1 = anual, 2 = one time cost
|
||||
"period_type" => 0, # 0 = monthly, 1 = annual, 2 = one time cost
|
||||
"start_date" => date('Y-m-d')
|
||||
];
|
||||
|
||||
@@ -502,8 +502,8 @@ class API_inserve extends API
|
||||
continue;
|
||||
}
|
||||
|
||||
// update the subscription if the countInserve and countSentri dont match
|
||||
// Or when sentriCompanyId and subscriptionInserveCompanyId dont match
|
||||
// update the subscription if the countInserve and countSentri don't match
|
||||
// Or when sentriCompanyId and subscriptionInserveCompanyId don't match
|
||||
if ((
|
||||
(int)$item['countInserve'] !== (int)$item['countSentri'] ||
|
||||
(int)$item['sentriCompanyId'] !== (int)$item['subscriptionInserveCompanyId'] ||
|
||||
@@ -680,7 +680,7 @@ class API_inserve extends API
|
||||
$existingLines[$item['product_code']] = $item;
|
||||
}
|
||||
|
||||
# Check if there are products that dont exists yet or have different descriptions
|
||||
# Check if there are products that don't exist yet or have different descriptions
|
||||
foreach ($subscriptionLines['lines'] as $subscriptionLine) {
|
||||
$product_code = $subscriptionLine['product_code'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user