<?php
/* * ********************************************************************
 * ProxmoxAddon product developed. (Aug 14, 2018)
 * *
 *
 *  CREATED BY MODULESGARDEN       ->       http://modulesgarden.com
 *  CONTACT                        ->       contact@modulesgarden.com
 *
 *
 * This software is furnished under a license and may be used and copied
 * only  in  accordance  with  the  terms  of such  license and with the
 * inclusion of the above copyright notice.  This software  or any other
 * copies thereof may not be provided or otherwise made available to any
 * other person.  No title to and  ownership of the  software is  hereby
 * transferred.
 *
 *
 * ******************************************************************** */

namespace ModulesGarden\ProxmoxAddon\App\UI\NodeDetail\Pages;


use MGProvision\Proxmox\v2\models\Node;
use ModulesGarden\ProxmoxAddon\App\Services\BaseService;
use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AjaxElementInterface;
use ModulesGarden\ProxmoxAddon\Core\UI\ResponseTemplates\RawDataJsonResponse;

class Subscription extends Summary implements AdminArea, AjaxElementInterface
{

    use BaseService;

    protected $id = 'mg-subscription';
    protected $name = 'mg-subscription-name';
    protected $title = 'mg-subscription-title';

    protected $vueComponent = true;
    protected $defaultVueComponentName = 'mg-subscription';

    public function initContent()
    {

    }

    public function returnAjaxData()
    {
        $data = [];
        $this->setServerId($this->getRequestValue('serverId'))
            ->getApi()
            ->setInstance();
        $node                                = new Node($this->getRequestValue('id'));
        $this->customTplVars['subscription'] = $node->getSubscription();
        $data['subscription']                = $node->getSubscription();
        return (new RawDataJsonResponse(['data' => $data]));
    }
}