src/Core/Client.php
public function execute(ClientRequestInterface $request, array $headers = null, array $clientOptions = [])
    {
        if ($request instanceof ContextAwareInterface) {
            $request->setContextIfNull($this->getConfig()->getContext());
        }
        $httpRequest = $this->createHttpRequest($request, $headers);

        try {
            $client = $this->getHttpClient();
            if ($client instanceof AdapterOptionInterface) {
                $httpResponse = $client->execute($httpRequest, $clientOptions);
            } else {
                $httpResponse = $client->execute($httpRequest);
            }
            $response = $request->buildResponse($httpResponse);
        } catch (ApiException $exception) {
            if ($exception instanceof InvalidTokenException && !$this->tokenRefreshed) {
                $this->tokenRefreshed = true;
                $this->getOauthManager()->refreshToken();
                return $this->execute($request);
            }
            if ($this->getConfig()->getThrowExceptions() || !$exception->getResponse() instanceof ResponseInterface) {
                throw $exception;
            }
            $httpResponse = $exception->getResponse();
            $this->logException($exception);
            $response = new ErrorResponse($exception, $request, $httpResponse);
        }
        $this->logDeprecatedRequest($httpResponse, $httpRequest);


        return $response;
    }
public function execute(ClientRequestInterface $request, array $headers = null, array $clientOptions = [])
    {
        if ($request instanceof ContextAwareInterface) {
            $request->setContextIfNull($this->getConfig()->getContext());
        }
        $httpRequest = $this->createHttpRequest($request, $headers);

        try {
            $client = $this->getHttpClient();
            if ($client instanceof AdapterOptionInterface) {
                $httpResponse = $client->execute($httpRequest, $clientOptions);
            } else {
                $httpResponse = $client->execute($httpRequest);
            }
            $response = $request->buildResponse($httpResponse);
        } catch (ApiException $exception) {
            if ($exception instanceof InvalidTokenException && !$this->tokenRefreshed) {
                $this->tokenRefreshed = true;
                $this->getOauthManager()->refreshToken();
                return $this->execute($request);
            }
            if ($this->getConfig()->getThrowExceptions() || !$exception->getResponse() instanceof ResponseInterface) {
                throw $exception;
            }
            $httpResponse = $exception->getResponse();
            $this->logException($exception);
            $response = new ErrorResponse($exception, $request, $httpResponse);
        }
        $this->logDeprecatedRequest($httpResponse, $httpRequest);


        return $response;
    }
public function execute ( ClientRequestInterface $ request , array $ headers = null , array $ clientOptions = [ ] ) { if ( $ request instanceof ContextAwareInterface ) { $ request -> setContextIfNull ( $ this -> getConfig ( ) -> getContext ( ) ) ; } $ httpRequest = $ this -> createHttpRequest ( $ request , $ headers ) ; try { $ client = $ this -> getHttpClient ( ) ; if ( $ client instanceof AdapterOptionInterface ) { $ httpResponse = $ client -> execute ( $ httpRequest , $ clientOptions ) ; } else { $ httpResponse = $ client -> execute ( $ httpRequest ) ; } $ response = $ request -> buildResponse ( $ httpResponse ) ; } catch ( ApiException $ exception ) { if ( $ exception instanceof InvalidTokenException && ! $ this -> tokenRefreshed ) { $ this -> tokenRefreshed = true ; $ this -> getOauthManager ( ) -> refreshToken ( ) ; return $ this -> execute ( $ request ) ; } if ( $ this -> getConfig ( ) -> getThrowExceptions ( ) || ! $ exception -> getResponse ( ) instanceof ResponseInterface ) { throw $ exception ; } $ httpResponse = $ exception -> getResponse ( ) ; $ this -> logException ( $ exception ) ; $ response = new ErrorResponse ( $ exception , $ request , $ httpResponse ) ; } $ this -> logDeprecatedRequest ( $ httpResponse , $ httpRequest ) ; return $ response ; }
Executes an API request synchronously

@param ClientRequestInterface $request
@param array $headers
@param array $clientOptions
@return ApiResponseInterface
@throws ApiException
@throws InvalidTokenException
Executes an API request synchronously