<?php
namespace WHMCS\Module\Addon\ProxyCheap;

use WHMCS\Module\Addon\ProxyCheap\Commands\GetBalance;

class AdminWidget extends \WHMCS\Module\AbstractWidget
{
    protected $title = 'ProxyCheap';
    protected $description = '';
    protected $weight = 150;
    protected $columns = 1;
    protected $cache = false;
    protected $cacheExpiry = 120;
    protected $requiredPermission = '';

    public function getData()
    {
        $apiParams = APIHelper::getApiCredentials();
        $balanceAPI = (new GetBalance($apiParams))->get();
        if($balanceAPI->balance)
        {
            return $balanceAPI->balance;
        }
        return 'Cannot fetch balance';
    }

    public function generateOutput($data)
    {

        return <<<EOF
<div class="widget-content-padded">
    Balance: {$data}
</div>
EOF;
    }
}