Get stream.

@param string $endpoint
@param array  $params

@return \EasyWeChat\Kernel\Http\StreamResponse
762852
protected function getStream(string $endpoint, array $params)
    {
        $response = $this->requestRaw($endpoint, 'POST', ['json' => $params]);

        if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
            return StreamResponse::buildFromPsrResponse($response);
        }

        return $this->castResponseToType($response, $this->app['config']->get('response_type'));
    }
1155852
private function sendRequest($endpoint, $headers = array())
    {
        $method = strtolower($this->config[$endpoint]['method']);

        if (! in_array($method, array('get', 'post', 'put', 'delete'))) {
            throw new \Exception(sprintf('%s method must be GET, POST, PUT, or DELETE', $endpoint));
        }

        if (isset($this->config['auth'])) {
            $response = $this->client->request(
                $method,
                $this->config[$endpoint]['path'],
                [
                    'auth' => [$this->config['auth']['user'], $this->config['auth']['password']],
                    'headers' => $headers,
                ]
            );
        } else {
            $response = $this->client->request(
                $method,
                $this->config[$endpoint]['path'],
                [
                    'headers' => $headers,
                ]
            );
        }

        return $response;
    }
289578
private function getResults($endpoint)
    {
        $results = [];
        $this->errorMessage = null;

        // Send the request
        $client = new Client(); //GuzzleHttp\Client

        do {
            try {
                $response = $client->request('GET', $endpoint, [
                    'headers' => $this->headers,
                    'query' => ['$select' => $this->select,
                        '$filter' => $this->filter,
                        '$orderby' => $this->orderby,
                        '$groupby' => $this->groupby,
                        '$having' => $this->having,
                        '$top' => $this->top,
                        '$skip' => $this->skip,
                        '$distinct' => $this->distinct
                    ],
                    'curl' => $this->setGetCurlopts(),
                ]);

            } catch (\GuzzleException $e) {
                $this->errorMessage = $e->getResponse()->getBody()->getContents();
                return false;
            } catch (\GuzzleHttp\Exception\ClientException $e) {
                $this->errorMessage = $e->getResponse()->getBody()->getContents();
                return false;
            } catch (\GuzzleHttp\Exception\RequestException $e) {
                $this->errorMessage = $e->getResponse()->getBody()->getContents();
                return false;
            } catch (\GuzzleHttp\Exception\ServerException $e) {
                $this->errorMessage = $e->getResponse()->getBody()->getContents();
                return false;
            }

            $r = json_decode($response->getBody(), true);

            // Get the number of rows returned
            $num = count($r);

            // Add this result set to the previous results
            $results = array_merge($results, $r);

            // Skip the rows we just got back if there were 1000 of them and query again
            ($num == 1000) ? $this->skip += 1000 : $this->skip = 0;

        } while ($this->skip > 0);

        $this->reset();
        return $results;
    }
52157
protected function sendRequest($endpoint, array $queryParams)
    {
        return $this->flexClient->sendRequest(
            $this->getApiName(),
            $this->getApiVersion(),
            $endpoint,
            $queryParams
        );
    }
544919
protected function getRatelimitBucket(string $endpoint) {
        if(empty($this->ratelimits[$endpoint])) {
            $bucket = $this->bucketName;
            $this->ratelimits[$endpoint] = new $bucket($this, $endpoint);
        }
        
        return $this->ratelimits[$endpoint];
    }
350762
public function getEndpoint($endpoint, $account = null)
    {
        $isSandbox = (new ConfigurationRepository)->getAccountKey('sandbox', true, $account);

        if ($isSandbox) {
            return $this->resolveUrl(MPESA_SANDBOX, $endpoint);
        }

        return $this->resolveUrl(MPESA_PRODUCTION, $endpoint);
    }
976815
public function makeRequest($method, $endpoint, array $data = [])
    {
        $response = $this->client->request($method, $endpoint, $data);

        return json_decode((string) $response->getBody());
    }
89417
public function makeRequest($endpoint, array $parameters = array(), $method = 'GET')
    {
        $response = array();

        // Validate if this endpoint has a BC url
        $bcEndpoint = null;
        if (!$this->bcAttempt) {
            if (!empty($this->bcRegexEndpoints)) {
                foreach ($this->bcRegexEndpoints as $regex => $bc) {
                    if (preg_match('@'.$regex.'@', $endpoint)) {
                        $this->bcAttempt = true;
                        $bcEndpoint = preg_replace('@'.$regex.'@', $bc, $endpoint);

                        break;
                    }
                }
            }
        }

        $url = $this->baseUrl.$endpoint;

        // Don't make the call if we're unit testing a BC endpoint
        if (!$bcEndpoint || !$this->bcTesting || ($bcEndpoint && $this->bcTesting && $this->bcAttempt)) {
            // Hack for unit testing to ensure this isn't being called due to a bad regex
            if ($this->bcTesting && !$this->bcAttempt) {
                $bt = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
                if (!is_array($this->bcTesting)) {
                    $this->bcTesting = array($this->bcTesting);
                }

                // The method is not catching the BC endpoint so fail the test
                if (in_array($bt[1]['function'], $this->bcTesting)) {
                    throw new \Exception($endpoint.' not matched in '.var_export($this->bcRegexEndpoints, true));
                }
            }
            $this->bcAttempt = false;

            if (strpos($url, 'http') === false) {
                $error = array(
                    'code'    => 500,
                    'message' => sprintf(
                        'URL is incomplete.  Please use %s, set the base URL as the third argument to $MauticApi->newApi(), or make $endpoint a complete URL.',
                        __CLASS__.'setBaseUrl()'
                    )
                );
            } else {
                try {
                    $settings = [];
                    if (method_exists($this, 'getTemporaryFilePath')) {
                        $settings['temporaryFilePath'] = $this->getTemporaryFilePath();
                    }
                    $response = $this->auth->makeRequest($url, $parameters, $method, $settings);

                    $this->getLogger()->debug('API Response', array('response' => $response));

                    if (!is_array($response)) {
                        $this->getLogger()->warning($response);

                        //assume an error
                        $error = array(
                            'code'    => 500,
                            'message' => $response
                        );
                    }

                    // @deprecated support for 2.6.0 to be removed in 3.0
                    if (!isset($response['errors']) && isset($response['error']) && isset($response['error_description'])) {
                        $message = $response['error'].': '.$response['error_description'];

                        $this->getLogger()->warning($message);

                        $error = array(
                            'code'    => 403,
                            'message' => $message
                        );
                    }
                } catch (\Exception $e) {
                    $this->getLogger()->error('Failed connecting to Mautic API: '.$e->getMessage(), array('trace' => $e->getTraceAsString()));

                    $error = array(
                        'code'    => $e->getCode(),
                        'message' => $e->getMessage()
                    );
                }
            }

            if (!empty($error)) {
                return array(
                    'errors' => array($error),
                    // @deprecated 2.6.0 to be removed 3.0
                    'error'  => $error
                );
            } elseif (!empty($response['errors'])) {
                $this->getLogger()->error('Mautic API returned errors: '.var_export($response['errors'], true));
            }

            // @deprecated 2.6.0 BC error handling
            // @todo remove in 3.0
            if (isset($response['error']) && !isset($response['errors'])) {
                if (isset($response['error_description'])) {
                    // BC Oauth2 error
                    $response['errors'] = array(
                        array(
                            'message' => $response['error_description'],
                            'type'    => $response['error']
                        )
                    );
                } elseif (isset($response['message'])) {
                    $response['errors'] = array(
                        $response['error']
                    );
                }
            }

            // Ensure a code is present in the error array
            if (!empty($response['errors'])) {
                $info = $this->auth->getResponseInfo();
                foreach ($response['errors'] as $key => $error) {
                    if (!isset($response['errors'][$key]['code'])) {
                        $response['errors'][$key]['code'] = $info['http_code'];
                    }
                }
            }
        }

        // Check for a 404 code and a BC URL then try again if applicable
        if ($bcEndpoint && ($this->bcTesting || (!empty($response['errors'][0]['code']) && (int) $response['errors'][0]['code'] === 404))) {
            $this->bcAttempt = true;

            return $this->makeRequest($bcEndpoint, $parameters, $method);
        }

        return $response;
    }
219586
public function get($params = [])
    {
        $result = $this->connection()->get($this->getEndpoint(), $params);

        return $this->collectionFromResult($result);
    }
1044086
public function get($endpoint, $options = [])
    {
        return $this->request('GET', 'rest/v1/users/' . $this->userId . '/' . $endpoint . '?' . http_build_query($options));
    }
131366
public function send($endpoint, $options = [], $body = '')
    {
        return $this->client->post(
            $endpoint . '?' . http_build_query($options),
            [
                'body' => $body,
            ]
        );
    }
1167200
public Response get(String endpoint) {
        return call(Method.GET, endpoint, null, null);
    }
14155
public function buildUrl($endpoint)
    {
        if (filter_var($endpoint, FILTER_VALIDATE_URL))
        {
            return $endpoint . '.' . $this->dataFormat;
        }

        if (substr($this->url, -1) != '/')
        {
            $this->url = $this->url . '/';
        }

        return $this->url . $endpoint . '.' . $this->dataFormat;
    }
259473
public function get(string $endPoint)
    {
        $parsedEndPoint = self::parseEndPoint($endPoint);
        return $this->sendRequest($parsedEndPoint, "GET");
    }
860670
public function contentEndpointRequest(string $endpoint, array $arguments, $body = ''): ResponseInterface
    {
        $headers = ['Dropbox-API-Arg' => json_encode($arguments)];

        if ($body !== '') {
            $headers['Content-Type'] = 'application/octet-stream';
        }

        try {
            $response = $this->client->post($this->getEndpointUrl('content', $endpoint), [
                'headers' => $this->getHeaders($headers),
                'body' => $body,
            ]);
        } catch (ClientException $exception) {
            throw $this->determineException($exception);
        }

        return $response;
    }
579029
public function sendRequest($endpoint, array $parameters, IncomingMessage $matchingMessage)
    {
        $parameters = array_replace_recursive([
            'access_token' => $this->config->get('token'),
        ], $parameters);

        return $this->http->post($this->facebookProfileEndpoint.$endpoint, [], $parameters);
    }
1337562
protected function get($endpoint, $params = [], $accessToken = null)
    {
        return $this->sendRequest(self::GET_METHOD, $endpoint, $params, $accessToken);
    }