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

use WHMCS\Module\Addon\ProxyCheap\AbstractCommand;
use WHMCS\Module\Addon\ProxyCheap\API;

class GetAvailableAuths extends AbstractCommand
{
    public function get()
    {
        $proxyid = (int) $this->input['proxy_id'];

        $api = new API();
        $request = $api->setKey($this->params['apikey'])
            ->setSecret($this->params['apisecret'])
            ->setHeaders()
            ->executeGET('proxies/' . $proxyid . '/change-authentication-type');

        if (!$request) {
            return ['message' => 'Proxy not found'];
        }
        return $request;
    }

    public function post()
    {
        $proxyid = (int) $this->input['proxy_account_id'];
        unset($this->input['proxy_account_id']);

        $api = new API();
        $request = $api->setKey($this->params['apikey'])
            ->setSecret($this->params['apisecret'])
            ->setHeaders()
            ->executePOST('proxies/' . $proxyid . '/change-authentication-type', $this->input);

        if (!$request) {
            return ['message' => 'Proxy not found'];
        }
        return $request;
    }
}