<?php
/**
 * Class DeleteAccount
 * User: ThurData
 * Date: 2019-09-17
 * Time: 17:12
 * @package ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Services\Create
 */

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


use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Interfaces\ApiService;
use ThurData\Servers\KerioEmail\App\Libs\Kerio\Components\Api\Soap\Models\Account;

class DeleteAccount extends ApiService
{

    /**
     * remove account in APi
     *
     * @return bool|mixed
     */
    public function process()
    {
        $account = new Account();
        $account->setId($this->formData['id']);

        $result = $this->api->account->delete($account);

        /**
         * problem with remove account
         */
        if(!$result)
        {
            $this->setError($this->api->account->getLastResult()->getLastErrorCode());
            return false;
        }

        return $result;
    }

}