<?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\Ressource;
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 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;
    }

}