Returns the response for a synchronous request

@param string $method HTTP method to use for the request
@param string $verb   ThisData verb to be used on this endpoint
@param array  $data   Request body data containing event metadata
425286
protected function synchronousExecute($method, $verb, array $data = [])
    {
        $request = new Request($method, $verb, [], $this->serialize($data));

        $response = $this->client->send($request);
        return $response;
    }
655251
private function doSend($method, array $data, $token = null)
    {
        try {
            $data['token'] = $token ?: $this->token;

            $this->eventDispatcher->dispatch(self::EVENT_REQUEST, new RequestEvent($data));

            $request = $this->createRequest($method, $data);

            /** @var ResponseInterface $response */
            $response = $this->client->send($request);
        } catch (\Exception $e) {
            throw new SlackException('Failed to send data to the Slack API', null, $e);
        }

        try {
            $responseData = json_decode($response->getBody()->getContents(), true);
            if (!is_array($responseData)) {
                throw new \Exception(sprintf(
                    'Expected JSON-decoded response data to be of type "array", got "%s"',
                    gettype($responseData)
                ));
            }

            $this->eventDispatcher->dispatch(self::EVENT_RESPONSE, new ResponseEvent($responseData));

            return $responseData;
        } catch (\Exception $e) {
            throw new SlackException('Failed to process response from the Slack API', null, $e);
        }
    }
1114913
protected function request($method, $relativeUrl, $data = null)
    {
        $request = new Request();

        $response = $request->request($method, $relativeUrl, $data);

        if ((isset($response['entity'])) and
            ($response['entity'] == $this->getEntity()))
        {
            $this->fill($response);

            return $this;
        }
        else
        {
            return static::buildEntity($response);
        }
    }
901466
protected function _sendRawRequest($url, $method = Request::METHOD_GET, $body = '', \Closure $initializeRequest = null)
    {
        $logSeverity = SolrLogManager::INFO;
        $exception = null;

        try {
            $request = $this->buildSolariumRequestFromUrl($url, $method);

            if($initializeRequest !== null) {
                $request = $initializeRequest($request);
            }

            $response = $this->executeRequest($request);
        } catch (HttpException $exception) {
            $logSeverity = SolrLogManager::ERROR;
            $response = new ResponseAdapter($exception->getBody(), $exception->getCode(), $exception->getMessage());
        }

        if ($this->configuration->getLoggingQueryRawPost() || $response->getHttpStatus() != 200) {
            $message = 'Querying Solr using '.$method;
            $this->writeLog($logSeverity, $message, $url, $response, $exception, $body);
        }

        return $response;
    }
183126
protected function httpRequest($action, $data, $method = 'POST', $options = [ ]) {
        $response = $this->{$this->http_request_type}($action, $data, $method, $options);
        $json = json_decode($response, true);
        if ($json === NULL) {
            throw new Sailthru_Client_Exception(
                "Response: {$response} is not a valid JSON",
                Sailthru_Client_Exception::CODE_RESPONSE_INVALID
            );
        }
        if (!empty($json['error'])) {
            throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
        }

        return $json;
    }
1230552
protected function doRequest(string $method, string $relativeUrl, array $data)
    {
        $url = 'https://doodle.com' . $relativeUrl;
        $cookieFileName = $this->getCookieFileName();

        $dataQuery = '';

        if (strpos($relativeUrl, 'api') !== false) {
            if (!empty($data)) {
                $dataQuery = json_encode($data);
            }
        } else {
            $dataQuery = http_build_query($data);
            $dataQuery = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '%5B%5D=', $dataQuery);
        }

        $ch = curl_init();

        switch ($method) {
            case 'GET':
                if (!empty($dataQuery)) {
                    $url .= '?' . $dataQuery;
                }
                if (strpos($relativeUrl, 'api') !== false) {
                    curl_setopt($ch, CURLOPT_HTTPHEADER, [
                        'Access-Token: ' . $this->token
                    ]);
                }
                break;
            case 'POST':
            case 'DELETE':
                if ($method === 'DELETE') {
                    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
                } else {
                    curl_setopt($ch, CURLOPT_POST, 1);
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $dataQuery);
                }
                if (strpos($relativeUrl, 'api') !== false) {
                    if ($method === 'POST') {
                        curl_setopt($ch, CURLOPT_HTTPHEADER, [
                            'Content-Type: application/json',
                            'Content-Length: ' . strlen($dataQuery)]
                        );
                    }
                }
                break;
        }

        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFileName);
        curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFileName);
        curl_setopt($ch, CURLOPT_VERBOSE, true);
        //$verbose = fopen('php://temp', 'wb+');
        curl_setopt($ch, CURLOPT_STDERR, $verbose);
        curl_setopt($ch, CURLINFO_HEADER_OUT, true);

        $result = curl_exec($ch);

        $info = curl_getinfo($ch);

        if ($result === FALSE) {
            printf("cUrl error (#%d): %s\n", curl_errno($ch), curl_error($ch));
            //$verboseLog = stream_get_contents($verbose);
            //echo "Verbose information:\n", $verboseLog, "\n";
        }
        //rewind($verbose);

        curl_close($ch);

        if (strpos($relativeUrl, 'api') !== false) {
            if ($method === 'DELETE') {
                return $info['http_code'] === 200;
            }
            if ($result) {
                if ($result[0] === 'E') {
                    $result = substr($result, 1);
                }

                return json_decode($result, true);
            }
        }

        return $result;
    }
959495
public function query($interface, $method, $data) {
        $headers = ['rpc_client_name' => $this->config[ 'name' ],
                    'rpc_token' => $this->config[ 'token' ],
                    'rpc_serialize' => $this->config[ 'serialize' ],
                    'rpc_interface' => $interface,
                    'rpc_method' => $method];
        if (IS_SWOOLE && \Co::getuid()) {
            return $this->queryCoroutine($headers, $data);
        } else {
            return $this->queryByRequest($headers, $data);
        }

    }
617420
public function sendRequest($action, $data = null, $method = RequestInterface::POST)
    {
        // don't throw exceptions for 4xx errors
        $this->httpClient->getEventDispatcher()->addListener(
            'request.error',
            function ($event) {
                if ($event['response']->isClientError()) {
                    $event->stopPropagation();
                }
            }
        );

        // Return the response we get back from Pin Payments
        return $this->httpClient->createRequest(
            $method,
            $this->getEndpoint() . $action,
            array('Authorization' => 'Basic ' . base64_encode($this->getSecretKey() . ':')),
            $data
        )->send();
    }
441490
protected function action($method, array $data = [], $flush = null)
    {
        $data = $this->data($data);

        $this->clearCache($flush);

        return $this->client->$method($data);
    }
1152312
public function request($method, $path, array $data = [])
    {
        try {
            $response = $this->httpClient->request($method, $path, $data);

            return json_decode($response->getBody()->getContents(), true);
        } catch (GuzzleException $e) {
            throw ClientException::newException($e, $method, $path, $data);
        }
    }
788599
public function methodIs($verb)
    {

        $method = $this->getVerb();
        $return = ($method === strtolower($verb)) ? true : false;

        return $return;
    }
491535
public function sendRequest($action, $data = null, $method = RequestInterface::POST)
    {
        // don't throw exceptions for 4xx errors, need the data for error messages
        $this->httpClient->getEventDispatcher()->addListener(
            'request.error',
            function ($event) {
                if ($event['response']->isClientError()) {
                    $event->stopPropagation();
                }
            }
        );

        $username = $this->getKeyId();
        $password = $this->getKeyPassword();
        $base64 = base64_encode($username.':'.$password);

        $url = $this->getEndpoint().$action;

        $headers = array(
            'Authorization' => 'Basic '.$base64,
            'Content-Type'  => 'application/json'
        );

        // For some reason the native json encoder built into Guzzle 3 is not encoding the nested data correctly,
        // breaking the http request. We need to do it manually.
        $data = json_encode($data);

        // Return the response we get back
        return $this->httpClient->createRequest($method, $url, $headers, $data)->send();
    }
265267
protected function doTransaction(
        $verb,
        $endpoint,
        $data = null,
        array $queryStringParams = null
    ) {
        $response = $this->sendRequest($verb, $endpoint, $data, $queryStringParams);

        if (!in_array($response->statusCode, [200, 204])) {
            $parsed = json_decode($response->rawResponse);
            $error = isset($parsed->error) ? $parsed->error : $parsed;
            throw new GatewayException(
                sprintf(
                    'Status Code: %s - %s',
                    $response->statusCode,
                    isset($error->message) ? $error->message : (string) $error
                )
            );
        }

        return $response->rawResponse;
    }
1367670
private function send($method, $url, array $data, array $headers, $cacheMinutes = 0, HttpExceptionHandler $handler = null)
    {
        if ($response = $this->getCachedResponse($method, $url, $data, $headers))
        {
            return $response;
        }

        try
        {
            // Execute the appropriate method on the Curl request class
            $curlResponse = $this->curl->$method($url, $data, $headers);
            // Convert the response
            $response = $this->responseParser->parse($curlResponse);

            $this->throwExceptionOnHttpErrors($response);
            $this->storeCachedResponse($response, $method, $url, $data, $headers, $cacheMinutes);

            return $response;
        }
        catch (CurlRequestException $exception)
        {
            $code = $exception->getCode();
            $message = $exception->getMessage();

            throw new RequestException($message, $code, $exception);
        }
        catch (HttpException $exception)
        {
            if ( ! $handler)
            {
                throw $exception;
            }

            return $handler->handleHttpException($exception);
        }
    }
953788
public function requestAsync($url, $method = 'GET', $data = [])
    {

        $stack = HandlerStack::create();
        $stack->push(ApiMiddleware::auth());
        $client = new Client(['handler' => $stack]);

        $promise = $client->requestAsync($method, $url, [
            'headers' => [
                'Authorization' => 'Bearer ' . $this->token
            ],
            'json' => $data,
            'content-type' => 'application/json'
        ]);

        return $promise;

    }
1211178
private function doRequest($method, $url, array $headers = [], array $data = [])
    {
        $request = new Request($method, $url, $headers, \GuzzleHttp\json_encode($data));
        $response = $this->httpClient->sendRequest($request);

        return new Response(
            $response->getStatusCode(),
            $response->getBody()->getContents(),
            /** @scrutinizer ignore-type */
            $response->getHeaders()
        );
    }
1227306
protected function sendRequest($method, $endpoint, $data = null)
    {
        return $this->httpClient->request(
            $method,
            $this->getEndpoint() . $endpoint,
            $this->getHeaders(),
            $data
        );
    }