|
|
@@ -13,6 +13,7 @@ use WHMCS\UsageBilling\Metrics\Metric;
|
|
|
use WHMCS\UsageBilling\Metrics\Units\WholeNumber;
|
|
|
use WHMCS\UsageBilling\Metrics\Usage;
|
|
|
use WHMCS\UsageBilling\Metrics\Units\GigaBytes;
|
|
|
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
|
|
|
|
|
|
class MyMetricProvider implements ProviderInterface
|
|
|
{
|
|
|
@@ -56,20 +57,28 @@ class MyMetricProvider implements ProviderInterface
|
|
|
|
|
|
public function usage()
|
|
|
{
|
|
|
+ $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
|
|
|
+ try {
|
|
|
+ $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
|
|
|
+ $domains = $api->getDomains(['id','name']);
|
|
|
+ } catch (KerioApiException $error) {
|
|
|
+ logModuleCall(
|
|
|
+ 'kerioEmail',
|
|
|
+ __FUNCTION__,
|
|
|
+ $error,
|
|
|
+ 'Debug Error',
|
|
|
+ $error->getMessage()
|
|
|
+ );
|
|
|
+ return ['error' => $error->getMessage()];
|
|
|
+ }
|
|
|
logModuleCall(
|
|
|
'kerioEmail',
|
|
|
__FUNCTION__,
|
|
|
- $this->moduleParams,
|
|
|
+ $params,
|
|
|
'Debug Usage',
|
|
|
- 'Test1'
|
|
|
+ $domains
|
|
|
);
|
|
|
-
|
|
|
- $domains =(new KerioManager())
|
|
|
- ->getApiByServer($this->moduleParams['serverid'])
|
|
|
- ->soap
|
|
|
- ->repository()
|
|
|
- ->domains()
|
|
|
- ->getAll();
|
|
|
+
|
|
|
|
|
|
$usage = [];
|
|
|
foreach ($domains as $domain)
|