<?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\Ressource;
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 UpdateRessourceStatus
 */
class UpdateRessourceStatus extends ApiService
{
    use ProductManagerHandler;

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

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

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

        return true;
    }

}