<?php

namespace ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap;

use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Repository\ClassOfServices;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccount;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccountAlias;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccountCos;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateAccountCosQuota;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateDistributionList;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateDomain;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateDomainAlias;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create\CreateRessource;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteAccount;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteAccountAlias;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteDistributionList;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteDomain;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteDomainAlias;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Delete\DeleteRessource;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Sso\ClientSingleSignOn;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Sso\ClientSingleSignOnToken;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\ChangePackage;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\ChangePackageConfigOptions;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\ChangePackageCosQuota;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\ChangePackageDedicatedCos;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\SuspendDomain;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateDomain;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UnsuspendDomain;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateAccount;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateAccountCosQuota;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateAccountPassword;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateAccountStatus;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateDistributionList;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateRessource;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateRessourceStatus;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Update\UpdateRessourcePassword;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Traits\ApiClientHandler;

/**
 *
 * Class return supported services
 *
 * Created by PhpStorm.
 * User: ThurData
 * Date: 03.10.19
 * Time: 13:15
 * Class Services
 */
class Services
{
    /**
     * API Client handler
     */
    use ApiClientHandler;

    /**
     * Services constructor.
     * @param Client $api
     */
    public function __construct(Client $api)
    {
        $this->setApi($api);
    }

    /**
     *
     * create account in kerio, depends of product configuration
     * @param string $type
     * @return CreateAccount|CreateAccountCos|CreateAccountCosQuota
     */
    public function createAccount($type = ClassOfServices::CUSTOM_KERIO)
    {
        switch ($type)
        {
            case ClassOfServices::CUSTOM_KERIO:
                $service = new CreateAccount($this->getApi());
                break;
            case ClassOfServices::KERIO_CONFIG_OPTIONS:
                $service = new CreateAccountCosQuota($this->getApi());
                break;
            case ClassOfServices::CLASS_OF_SERVICE_QUOTA:
                $service = new CreateAccountCosQuota($this->getApi());
                break;
            default:
                $service = new CreateAccountCosQuota($this->getApi());
                break;
        }

        return $service;
    }

    /**
     * create alias for account in kerio
     *
     * @return CreateAccountAlias
     */
    public function createAccountAlias()
    {
        return new CreateAccountAlias($this->getApi());
    }

    /**
     * create distribution list (mailing list)
     *
     * @return CreateDistributionList
     */
    public function createDistributionList()
    {
        return new CreateDistributionList($this->getApi());
    }

    /**
     * create domain in kerio (main domain for account)
     *
     *
     * @return CreateDomain
     */
    public function createDomain()
    {
        return new CreateDomain($this->getApi());
    }

    /**
     * create alias domain for account
     *
     * @return CreateDomainAlias
     */
    public function createDomainAlias()
    {
        return new CreateDomainAlias($this->getApi());
    }

    /**
     * create ressource for account
     *
     * @return CreateRessource
     */
    public function createRessource()
    {
        return new CreateRessource($this->getApi());
    }

    /**
     *
     * change product package
     *
     * @return ChangePackage
     */
    public function changePackages($type = ClassOfServices::CUSTOM_KERIO)
    {
        switch ($type)
        {
            case ClassOfServices::CUSTOM_KERIO:
                $service = new ChangePackage($this->getApi());
                break;
            case ClassOfServices::KERIO_CONFIG_OPTIONS:
                $service = new ChangePackageConfigOptions($this->getApi());
                break;
            case ClassOfServices::CLASS_OF_SERVICE_QUOTA:
                $service = new ChangePackageCosQuota($this->getApi());
                break;
            default:
                $service = new ChangePackageDedicatedCos($this->getApi());
                break;
        }

        return $service;
    }

    /**
     * update account in panel
     *
     * @param string $type
     * @return UpdateAccount|UpdateAccountCosQuota
     */
    public function updateAccount($type = ClassOfServices::CUSTOM_KERIO)
    {
        switch ($type)
        {
            case ClassOfServices::CUSTOM_KERIO:
                $service = new UpdateAccount($this->getApi());
                break;
            case ClassOfServices::KERIO_CONFIG_OPTIONS:
                $service = new UpdateAccount($this->getApi());
                break;
            case ClassOfServices::CLASS_OF_SERVICE_QUOTA:
                $service = new UpdateAccountCosQuota($this->getApi());
                break;
            default:
                $service = new UpdateAccount($this->getApi());
                break;
        }

        return $service;
    }

    /**
     * update account status
     *
     * @return UpdateAccountStatus
     */
    public function updateAccountStatus()
    {
        return new UpdateAccountStatus($this->getApi());
    }

    /**
     * update ressource
     *
     * @return UpdateRessource
     */
    public function updateRessource()
    {
        return new UpdateRessource($this->getApi());
    }

    /**
     * update ressource status
     *
     * @return UpdateRessourceStatus
     */
    public function updateRessourceStatus()
    {
        return new UpdateRessourceStatus($this->getApi());
    }

    /**
     * change password service
     *
     * @return UpdateAccountPassword
     */
    public function updateAccountPassword()
    {
        return new UpdateAccountPassword($this->getApi());
    }

    /**
     * change password service
     *
     * @return UpdateRessourcePassword
     */
    public function updateRessourcePassword()
    {
        return new UpdateRessourcePassword($this->getApi());
    }

    /**
     * distribution (mailing) list update service
     *
     * @return UpdateDistributionList
     */
    public function updateDistributionList()
    {
        return new UpdateDistributionList($this->getApi());
    }

    /**
     * suspend domain in kerio
     *
     * @return SuspendDomain
     */
    public function suspendDomain()
    {
        return new SuspendDomain($this->getApi());
    }

    /**
     * unsuspend domain
     *
     * @return UnsuspendDomain
     */
    public function unsuspendDomain()
    {
        return new UnsuspendDomain($this->getApi());
    }

    /**
     * delete account in panel
     *
     * @return DeleteAccount
     */
    public function deleteAccount()
    {
        return new DeleteAccount($this->getApi());
    }

    /**
     * delete ressource in panel
     *
     * @return DeleteRessource
     */
    public function deleteRessource()
    {
        return new DeleteRessource($this->getApi());
    }

    /**
     * delete domain & each related things
     *
     * @return DeleteDomain
     */
    public function deleteDomain()
    {
        return new DeleteDomain($this->getApi());
    }

    /**
     * delete account alias
     *
     * @return DeleteAccountAlias
     */
    public function deleteAccountAlias()
    {
        return new DeleteAccountAlias($this->getApi());
    }

    /**
     * delete distribution list (mailing list)
     *
     * @return DeleteDistributionList
     */
    public function deleteDistributionList()
    {
        return new DeleteDistributionList($this->getApi());
    }

    /**
     * delete domain alias
     *
     * @return DeleteDomainAlias
     */
    public function deleteDomainAlias()
    {
        return new DeleteDomainAlias($this->getApi());
    }

    /**
     *
     * return sso token
     * @return ClientSingleSignOnToken
     */
    public function clientSingleSignOnToken()
    {
        return new ClientSingleSignOnToken($this->getApi());
    }

}