<?php
/**
 * Class DeleteRessource
 * 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\Ressource;

class DeleteRessource extends ApiService
{

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

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

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

        return $result;
    }

}