protected function request($method, $uri, $headers, $payload = null, $responseHeader = false)
    {
        $ch = curl_init($uri);

        $options = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_HEADER => $responseHeader,
            CURLOPT_HTTPHEADER => $headers,
        ];

        $options[CURLOPT_CUSTOMREQUEST] = $method;

        if (!is_null($payload)) {
            $options[CURLOPT_POSTFIELDS] = $payload;
        }

        curl_setopt_array($ch, $options);

        $response = curl_exec($ch);

        if (false === $response) {
            throw new \RuntimeException(curl_error($ch));
        }

        $info = curl_getinfo($ch);
        if (200 != $info['http_code'] && 201 != $info['http_code']) {
            throw new \RuntimeException('Error sending request: '.$info['http_code'].' msg: '.$response);
        }

        return $response;
    }
protected function request($method, $uri, $headers, $payload = null, $responseHeader = false)
    {
        $ch = curl_init($uri);

        $options = [
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_HEADER => $responseHeader,
            CURLOPT_HTTPHEADER => $headers,
        ];

        $options[CURLOPT_CUSTOMREQUEST] = $method;

        if (!is_null($payload)) {
            $options[CURLOPT_POSTFIELDS] = $payload;
        }

        curl_setopt_array($ch, $options);

        $response = curl_exec($ch);

        if (false === $response) {
            throw new \RuntimeException(curl_error($ch));
        }

        $info = curl_getinfo($ch);
        if (200 != $info['http_code'] && 201 != $info['http_code']) {
            throw new \RuntimeException('Error sending request: '.$info['http_code'].' msg: '.$response);
        }

        return $response;
    }
protected function request ( $ method , $ uri , $ headers , $ payload = null , $ responseHeader = false ) { $ ch = curl_init ( $ uri ) ; $ options = [ CURLOPT_RETURNTRANSFER => true , CURLOPT_SSL_VERIFYPEER => false , CURLOPT_HEADER => $ responseHeader , CURLOPT_HTTPHEADER => $ headers , ] ; $ options [ CURLOPT_CUSTOMREQUEST ] = $ method ; if ( ! is_null ( $ payload ) ) { $ options [ CURLOPT_POSTFIELDS ] = $ payload ; } curl_setopt_array ( $ ch , $ options ) ; $ response = curl_exec ( $ ch ) ; if ( false === $ response ) { throw new \ RuntimeException ( curl_error ( $ ch ) ) ; } $ info = curl_getinfo ( $ ch ) ; if ( 200 != $ info [ 'http_code' ] && 201 != $ info [ 'http_code' ] ) { throw new \ RuntimeException ( 'Error sending request: ' . $ info [ 'http_code' ] . ' msg: ' . $ response ) ; } return $ response ; }
Send the request to API.

@param string $method
@param string $uri
@param array  $headers
@param string $payload
@param bool   $responseHeader

@throws \RuntimeException

@return string

@codeCoverageIgnore
Send the request to API .