Skip to content

Commit

Permalink
Update WHMCS Domains Reseller v3.0.9
Browse files Browse the repository at this point in the history
Update WHMCS Domains Reseller v3.0.9
  • Loading branch information
rwill76 committed May 11, 2022
1 parent 9e69825 commit 7dad0d2
Show file tree
Hide file tree
Showing 2 changed files with 460 additions and 350 deletions.
28 changes: 24 additions & 4 deletions RadWebHosting/Core/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class Call
* @param Configuration $config
* @param $params
*/
public function __construct(Configuration $config, $params)
public function __construct(Configuration $config, $params = [])
{
$this->config = $config;
$this->params = $params;
Expand All @@ -72,9 +72,16 @@ public function process()
$url = "{$this->config->ApiEndpoint}/{$this->action}";

$client = new Client();
$request = $client->createRequest($this->type, $url, ["headers" => $this->config->getAuthHeaders(), $this->getParamKeyName() => $this->params]);

$output = $client->send($request)->getBody()->getContents();
if($this->isWhmcsVersionHigherOrEqual('8.0.0'))
{
$params = $this->type === self::TYPE_POST ? $this->params : [];
$request = $client->request($this->type, $url, ["headers" => $this->config->getAuthHeaders(), "form_params" => $params]);
$output = $request->getBody()->getContents();
} else
{
$request = $client->createRequest($this->type, $url, ["headers" => $this->config->getAuthHeaders(), $this->getParamKeyName() => $this->params]);
$output = $client->send($request)->getBody()->getContents();
}
}
catch (\GuzzleHttp\Exception\ClientException $ex)
{
Expand Down Expand Up @@ -141,4 +148,17 @@ protected function getParamKeyName()

return $result;
}

private function isWhmcsVersionHigherOrEqual($toCompare)
{
if (isset($GLOBALS['CONFIG']['Version']))
{
$version = explode('-', $GLOBALS['CONFIG']['Version']);
return (version_compare($version[0], $toCompare, '>='));
}

global $whmcs;

return (version_compare($whmcs->getVersion()->getRelease(), $toCompare, '>='));
}
}
Loading

0 comments on commit 7dad0d2

Please sign in to comment.