protected function call($action, array $parameters = [])
    {
        if ($this->batch) {

            $query = ['api_action' => $action];

            foreach ($parameters as $key => $value) {
                if ($value !== null) {
                    $query[urlencode($key)] = urlencode($value);
                }
            }

            $this->batch->addRequest($query);

            return true;
        }

        $curl = curl_init();

        if (!$curl) {
            return false;
        }

        $query = "api_key={$this->key}&api_action={$action}";

        foreach ($parameters as $key => $value) {
            if ($value !== null) {
                $query .= sprintf('&%s=%s', urlencode($key), urlencode($value));
            }
        }

        if ($this->debug) {
            return $query;
        }

        $this->options[CURLOPT_URL]            = 'https://api.linode.com/';
        $this->options[CURLOPT_POST]           = true;
        $this->options[CURLOPT_POSTFIELDS]     = $query;
        $this->options[CURLOPT_RETURNTRANSFER] = true;
        $this->options[CURLOPT_SSLVERSION]     = CURL_SSLVERSION_TLSv1_2;

        curl_setopt_array($curl, $this->options);

        $result = curl_exec($curl);

        curl_close($curl);

        $json = json_decode($result, true);

        if (!$json) {
            throw new \RuntimeException('Empty response');
        }

        $error = reset($json['ERRORARRAY']);

        if ($error) {
            throw new LinodeException($error['ERRORMESSAGE'], $error['ERRORCODE']);
        }

        return $json['DATA'];
    }
protected function call($action, array $parameters = [])
    {
        if ($this->batch) {

            $query = ['api_action' => $action];

            foreach ($parameters as $key => $value) {
                if ($value !== null) {
                    $query[urlencode($key)] = urlencode($value);
                }
            }

            $this->batch->addRequest($query);

            return true;
        }

        $curl = curl_init();

        if (!$curl) {
            return false;
        }

        $query = "api_key={$this->key}&api_action={$action}";

        foreach ($parameters as $key => $value) {
            if ($value !== null) {
                $query .= sprintf('&%s=%s', urlencode($key), urlencode($value));
            }
        }

        if ($this->debug) {
            return $query;
        }

        $this->options[CURLOPT_URL]            = 'https://api.linode.com/';
        $this->options[CURLOPT_POST]           = true;
        $this->options[CURLOPT_POSTFIELDS]     = $query;
        $this->options[CURLOPT_RETURNTRANSFER] = true;
        $this->options[CURLOPT_SSLVERSION]     = CURL_SSLVERSION_TLSv1_2;

        curl_setopt_array($curl, $this->options);

        $result = curl_exec($curl);

        curl_close($curl);

        $json = json_decode($result, true);

        if (!$json) {
            throw new \RuntimeException('Empty response');
        }

        $error = reset($json['ERRORARRAY']);

        if ($error) {
            throw new LinodeException($error['ERRORMESSAGE'], $error['ERRORCODE']);
        }

        return $json['DATA'];
    }
protected function call ( $ action , array $ parameters = [ ] ) { if ( $ this -> batch ) { $ query = [ 'api_action' => $ action ] ; foreach ( $ parameters as $ key => $ value ) { if ( $ value !== null ) { $ query [ urlencode ( $ key ) ] = urlencode ( $ value ) ; } } $ this -> batch -> addRequest ( $ query ) ; return true ; } $ curl = curl_init ( ) ; if ( ! $ curl ) { return false ; } $ query = "api_key={$this->key}&api_action={$action}" ; foreach ( $ parameters as $ key => $ value ) { if ( $ value !== null ) { $ query .= sprintf ( '&%s=%s' , urlencode ( $ key ) , urlencode ( $ value ) ) ; } } if ( $ this -> debug ) { return $ query ; } $ this -> options [ CURLOPT_URL ] = 'https://api.linode.com/' ; $ this -> options [ CURLOPT_POST ] = true ; $ this -> options [ CURLOPT_POSTFIELDS ] = $ query ; $ this -> options [ CURLOPT_RETURNTRANSFER ] = true ; $ this -> options [ CURLOPT_SSLVERSION ] = CURL_SSLVERSION_TLSv1_2 ; curl_setopt_array ( $ curl , $ this -> options ) ; $ result = curl_exec ( $ curl ) ; curl_close ( $ curl ) ; $ json = json_decode ( $ result , true ) ; if ( ! $ json ) { throw new \ RuntimeException ( 'Empty response' ) ; } $ error = reset ( $ json [ 'ERRORARRAY' ] ) ; if ( $ error ) { throw new LinodeException ( $ error [ 'ERRORMESSAGE' ] , $ error [ 'ERRORCODE' ] ) ; } return $ json [ 'DATA' ] ; }
Performs specified call to Linode API.

@param string $action
@param array  $parameters

@throws LinodeException
@throws \Exception

@return array|bool
Performs specified call to Linode API .