<?php

namespace ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Services\Update;


use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Interfaces\ApiService;
use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Models\Account;
use ModulesGarden\Servers\ZimbraEmail\App\Libs\Zimbra\Components\Api\Soap\Traits\ProductManagerHandler;

/**
 *
 * Created by PhpStorm.
 * User: Tomasz Bielecki ( tomasz.bi@modulesgarden.com )
 * 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->getError());
            return false;
        }

        return true;
    }

}