<?php

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


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

/**
 *
 * Created by PhpStorm.
 * User: ThurData
 * Date: 09.10.19
 * Time: 09:00
 * Class UpdateAccountStatus
 */
class UpdateAccountStatus extends ApiService
{
    use ProductManagerHandler;

    public function process()
    {
        $model = new Account();
        $model->setId($this->formData['id']);
        $model->setAttr(Account::ATTR_ACCOUNT_STATUS, $this->formData['status']);

        $result = $this->api->account->update($model);

        if(!$result)
        {
            $this->setError($this->api->account->getLastResult()->getLastErrorCode());
            return false;
        }

        return true;
    }

}