فهرست منبع

suspendAccount - get userlist

andre 2 سال پیش
والد
کامیت
713c9d4591
1فایلهای تغییر یافته به همراه37 افزوده شده و 13 حذف شده
  1. 37 13
      app/Http/Actions/SuspendAccount.php

+ 37 - 13
app/Http/Actions/SuspendAccount.php

@@ -7,6 +7,7 @@ use ThurData\Servers\KerioEmail\App\Enums\Response;
 use ThurData\Servers\KerioEmail\App\Helpers\KerioManager;
 use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
 use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
+use ThurData\Servers\KerioEmail\Api\KerioWhmcs;
 
 /**
  *
@@ -51,20 +52,43 @@ class SuspendAccount extends AddonController
      */
     protected function kerioRunService($params = null)
     {
-        $service = (new KerioManager())
-            ->getApiByServer($params['serverid'])
-            ->soap
-            ->service()
-            ->suspendDomain()
-            ->setFormData($params)
-        ;
-
-        $result = $service->run();
-
-        if(!$result)
-        {
-            return $service->getError();
+        $api = new KerioWhmcs('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
+            $domainID = $api->getDomainId($params['domain']);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }             
+        if ($domainID === FALSE) {
+            return "Error: Domain $domain not found";
         }
+        try {
+            $users = $api->getUsers(['id'], $domainID);
+        } catch (KerioApiException $error) {
+            logModuleCall(
+                'kerioEmail',
+                __FUNCTION__,
+                $error,
+                'Debug Error',
+                $error->getMessage()
+            );
+            return ['error' => $error->getMessage()];
+        }             
+
+        logModuleCall(
+            'kerioEmail',
+            __FUNCTION__,
+            $domainID,
+            'Debug SuspendAccount',
+            $users
+        );
 
         /**
          * return success response