<?php

namespace MGModule\DNSManager2\mgLibs\whmcsAPI;
use MGModule\DNSManager2 as main;

class whmcsAPI{
    
    static function getAdmin(){
          static $username;
          
          if(empty($username))
          {
                $data = main\mgLibs\MySQL\query::select(
                                array('username')
                                , 'tbladmins'
                                , array()
                                , array()
                                , 1
                        )->fetch();
                $username = $data['username'];
          }
          
          return $username;
    }


    static function request($command,$config){
        $result = localAPI($command,$config,self::getAdmin());
       
        if($result['result'] == 'error')
        {
            throw new main\mgLibs\exceptions\whmcsAPI($result['message']);
        }
        
        return $result;
    }
}