Browse Source

update createAccount

andre 2 years ago
parent
commit
2cc319d003
1 changed files with 16 additions and 32 deletions
  1. 16 32
      app/Http/Actions/CreateAccount.php

+ 16 - 32
app/Http/Actions/CreateAccount.php

@@ -11,6 +11,7 @@ use ThurData\Servers\KerioEmail\App\Traits\ExtensionsCheckerTrait;
 use ThurData\Servers\KerioEmail\Core\App\Controllers\Instances\AddonController;
 use ThurData\Servers\KerioEmail\App\Traits\HostingService;
 use \ThurData\Servers\KerioEmail\Core\UI\Traits\WhmcsParams;
+use ThurData\Servers\KerioEmail\Api\KerioConnectApi;
 
 /**
  *
@@ -69,39 +70,22 @@ class CreateAccount extends AddonController
      */
     protected function kerioRunService($params = null)
     {
-        /**
-         *
-         * get soap create domain  service
-         */
-        $service =(new KerioManager())
-            ->getApiByServer($params['serverid'])
-            ->soap
-            ->service()
-            ->createDomain();
-
-        /**
-         * product manager allow to check product settings
-         */
-        $productManager = new ProductManager();
-        $productManager->loadByHostingId($params['serviceid']);
-
-        /**
-         *
-         * set params
-         * run service (Create domain in Kerio API)
-         */
-        $result = $service
-            ->setProductManager($productManager)
-            ->setFormData($params)
-            ->run();
+        $api = new KerioConnectApi('whmcsKerioEmail', 'Thurdata', '1.0');
+        try {
+            $api->login($params['serverhostname'], $params['serverusername'], $params['serverpassword']);
+            $result = $api->sendRequest('Domains.get');
+            $api->logout();
+        } catch (KerioApiException $error) {
+            return ['error' => $error->getMessage()];
+        }             
 
-        /**
-         * check service result & return error
-         */
-        if(!$result)
-        {
-            return $service->getError();
-        }
+        logModuleCall(
+            'kerioEmail',
+            __FUNCTION__,
+            $result,
+            'Debug Features & Attributes',
+            $params
+        );
 
         /**
          * return success response