public function sendRequest(
        string $endpoint,
        array $queryString = []
    ) {
        $headers = [
            'Accept' => 'application/json',
        ];

        if ($this->getApiKey() !== null) {
            $headers['Authorization'] = base64_encode($this->getApiKey());
        }

        $curl = curl_init();

        $host = $this->isSafe === true
            ? self::BASE_SAFE_HOST
            : self::BASE_HOST;

        $requestPath = $host . $endpoint . '?' . http_build_query($queryString);

        if ($this->curlConfigurator !== null) {
            ($this->curlConfigurator)($curl);
        }

        curl_setopt($curl, CURLOPT_URL, $requestPath);
        curl_setopt($curl, CURLOPT_HTTPGET, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->convertArrayToCurlHeaders($headers));

        $response = curl_exec($curl);

        if (mb_strlen($curlError = curl_error($curl)) > 0) {
            throw new RuntimeException(sprintf(
                'cURL request error: %s',
                $curlError
            ));
        }

        curl_close($curl);

        return json_decode($response, true);
    }
public function sendRequest(
        string $endpoint,
        array $queryString = []
    ) {
        $headers = [
            'Accept' => 'application/json',
        ];

        if ($this->getApiKey() !== null) {
            $headers['Authorization'] = base64_encode($this->getApiKey());
        }

        $curl = curl_init();

        $host = $this->isSafe === true
            ? self::BASE_SAFE_HOST
            : self::BASE_HOST;

        $requestPath = $host . $endpoint . '?' . http_build_query($queryString);

        if ($this->curlConfigurator !== null) {
            ($this->curlConfigurator)($curl);
        }

        curl_setopt($curl, CURLOPT_URL, $requestPath);
        curl_setopt($curl, CURLOPT_HTTPGET, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
        curl_setopt($curl, CURLOPT_HTTPHEADER, $this->convertArrayToCurlHeaders($headers));

        $response = curl_exec($curl);

        if (mb_strlen($curlError = curl_error($curl)) > 0) {
            throw new RuntimeException(sprintf(
                'cURL request error: %s',
                $curlError
            ));
        }

        curl_close($curl);

        return json_decode($response, true);
    }
public function sendRequest ( string $ endpoint , array $ queryString = [ ] ) { $ headers = [ 'Accept' => 'application/json' , ] ; if ( $ this -> getApiKey ( ) !== null ) { $ headers [ 'Authorization' ] = base64_encode ( $ this -> getApiKey ( ) ) ; } $ curl = curl_init ( ) ; $ host = $ this -> isSafe === true ? self :: BASE_SAFE_HOST : self :: BASE_HOST ; $ requestPath = $ host . $ endpoint . '?' . http_build_query ( $ queryString ) ; if ( $ this -> curlConfigurator !== null ) { ( $ this -> curlConfigurator ) ( $ curl ) ; } curl_setopt ( $ curl , CURLOPT_URL , $ requestPath ) ; curl_setopt ( $ curl , CURLOPT_HTTPGET , true ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , 1 ) ; curl_setopt ( $ curl , CURLOPT_SSLVERSION , CURL_SSLVERSION_TLSv1_2 ) ; curl_setopt ( $ curl , CURLOPT_HTTPHEADER , $ this -> convertArrayToCurlHeaders ( $ headers ) ) ; $ response = curl_exec ( $ curl ) ; if ( mb_strlen ( $ curlError = curl_error ( $ curl ) ) > 0 ) { throw new RuntimeException ( sprintf ( 'cURL request error: %s' , $ curlError ) ) ; } curl_close ( $ curl ) ; return json_decode ( $ response , true ) ; }
Sends request to endpoint and returns decoded response.

@param string $endpoint
@param array  $queryString

@throws RuntimeException if cURL error occurred

@return mixed
Sends request to endpoint and returns decoded response .