<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\Http\Actions;


use ModulesGarden\Servers\ZimbraEmail\App\Enums\ControllerEnums;
use ModulesGarden\Servers\ZimbraEmail\App\Enums\Zimbra;
use ModulesGarden\Servers\ZimbraEmail\App\Helpers\BuildUrlExtended;
use ModulesGarden\Servers\ZimbraEmail\App\Helpers\ZimbraManager;
use ModulesGarden\Servers\ZimbraEmail\App\Libs\Product\ProductManager;
use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Connection;
use ModulesGarden\Servers\ZimbraEmail\App\Traits\ServerParams;
use ModulesGarden\Servers\ZimbraEmail\Core\App\Controllers\Instances\AddonController;
use ModulesGarden\Servers\ZimbraEmail\Core\Helper;
use ModulesGarden\Servers\ZimbraEmail\Core\UI\Traits\WhmcsParams;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * Date: 08.11.19
 * Time: 09:47
 * Class AdminSingleSignOn
 */
class ServiceSingleSignon extends AddonController
{
    use WhmcsParams;
    use ServerParams;
    public function execute($params = null)
    {
        try{

            $productManager = new ProductManager();
            $productManager->loadByHostingId($this->getRequestValue('id'));

            return [
                'success'    => true,
                'redirectTo' => $productManager->getClientUrl()
            ];

        }catch (\Exception $e)
        {
            return ['error' => $e->getMessage()];
        }
    }
}