protected function send(
        $method,
        $path,
        array $headers = array(),
        $queryString = null,
        array $links = null,
        $noCache = false,
        $absolutePath = false
    )
    {
        $headers = $this->initHeaders($headers);
        $transport = HttpTransportFactory::build(
            'curl',
            $this->getCacher(),
            $this->getLogger()
        );

        if (!$absolutePath) {
            $path = $this->getApiEndpointPath($path);
        }

        $transport
            ->setMethod($method)
            ->setPath($path)
            ->setHeaders($headers)
        ;

        if (null !== $queryString) {
            $transport->setQueryString($queryString);
        }
        if (null !== $links) {
            $transport->setLinks($links);
        }

        try {
            $response = $transport->send();
        } catch (ApiHttpResponseException $exception) {
            if (
                401 === $exception->getStatusCode() &&
                $this->container->has('da_oauth_client.authorization_refresher.oauth')
            ) {
                // Try to refresh the access token.
                $oauthRefresher = $this->container->get('da_oauth_client.authorization_refresher.oauth');
                $oauthRefresher->refresh();

                $response = $transport->send($noCache);
            } else {
                throw $exception;
            }
        }

        return $response;
    }
protected function send(
        $method,
        $path,
        array $headers = array(),
        $queryString = null,
        array $links = null,
        $noCache = false,
        $absolutePath = false
    )
    {
        $headers = $this->initHeaders($headers);
        $transport = HttpTransportFactory::build(
            'curl',
            $this->getCacher(),
            $this->getLogger()
        );

        if (!$absolutePath) {
            $path = $this->getApiEndpointPath($path);
        }

        $transport
            ->setMethod($method)
            ->setPath($path)
            ->setHeaders($headers)
        ;

        if (null !== $queryString) {
            $transport->setQueryString($queryString);
        }
        if (null !== $links) {
            $transport->setLinks($links);
        }

        try {
            $response = $transport->send();
        } catch (ApiHttpResponseException $exception) {
            if (
                401 === $exception->getStatusCode() &&
                $this->container->has('da_oauth_client.authorization_refresher.oauth')
            ) {
                // Try to refresh the access token.
                $oauthRefresher = $this->container->get('da_oauth_client.authorization_refresher.oauth');
                $oauthRefresher->refresh();

                $response = $transport->send($noCache);
            } else {
                throw $exception;
            }
        }

        return $response;
    }
protected function send ( $ method , $ path , array $ headers = array ( ) , $ queryString = null , array $ links = null , $ noCache = false , $ absolutePath = false ) { $ headers = $ this -> initHeaders ( $ headers ) ; $ transport = HttpTransportFactory :: build ( 'curl' , $ this -> getCacher ( ) , $ this -> getLogger ( ) ) ; if ( ! $ absolutePath ) { $ path = $ this -> getApiEndpointPath ( $ path ) ; } $ transport -> setMethod ( $ method ) -> setPath ( $ path ) -> setHeaders ( $ headers ) ; if ( null !== $ queryString ) { $ transport -> setQueryString ( $ queryString ) ; } if ( null !== $ links ) { $ transport -> setLinks ( $ links ) ; } try { $ response = $ transport -> send ( ) ; } catch ( ApiHttpResponseException $ exception ) { if ( 401 === $ exception -> getStatusCode ( ) && $ this -> container -> has ( 'da_oauth_client.authorization_refresher.oauth' ) ) { // Try to refresh the access token. $ oauthRefresher = $ this -> container -> get ( 'da_oauth_client.authorization_refresher.oauth' ) ; $ oauthRefresher -> refresh ( ) ; $ response = $ transport -> send ( $ noCache ) ; } else { throw $ exception ; } } return $ response ; }
Send a request to an API.

@param string       $method       The HTTP method.
@param string       $path         The relative path to the webservice.
@param array        $headers      The optionnal headers.
@param string|array $queryString  The specific queryString to the webservice.
@param array        $links        Array of resources to link.
@param boolean      $noCache      To force the request without check if a cache response exist.
@param boolean      $absolutePath To use absolute path instead of build it with api endpoint.

@return Da\ApiClientBundle\Http\Response

@throws ApiHttpResponseException
Send a request to an API .