private function doRequest($path, $headers = [])
    {
        if (!$this->isAvailable()) {
            throw new NotAvailableException('Service not available.');
        }

        if ($this->loadBalance !== null) {
            $uri = $this->loadBalance->getUri($this->serviceName);
            $this->zendClient->setUri($uri);
        }
        if ($this->appendPath && strlen($path) > 0 && $this->zendClient->getUri()->getPath() != '/') {
            $path = $this->zendClient->getUri()->getPath() . $path;
        }
        $this->zendClient->getUri()->setPath($path);

        $this->zendClient->getRequest()->getHeaders()->addHeaders($headers);

        if (!$this->zendClient->getRequest()->getHeaders()->has('X-Request-Id')) {
            $this->addRequestId();
        }

        $this->addRequestName($this->serviceName);

        $this->getEventManager()->trigger('request.pre', $this);

        $this->responseTime = 0;

        try {
            $requestTime = microtime(true);

            $zendHttpResponse = $this->zendClient->send();

            $this->responseTime = (float) sprintf('%.2f', (microtime(true) - $requestTime) * 1000);

            $this->addRequestTime($this->responseTime);

            $response = new Response($this->zendClient, $zendHttpResponse, $this->depth);
            $this->reportSuccess();
        } catch (RuntimeException $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), $ex->getCode(), $ex);
        } catch (\Exception $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), 500, $ex);
        }

        $this->getEventManager()->trigger('request.post', $this);

        $content = $response->getContent();

        return $content;
    }
private function doRequest($path, $headers = [])
    {
        if (!$this->isAvailable()) {
            throw new NotAvailableException('Service not available.');
        }

        if ($this->loadBalance !== null) {
            $uri = $this->loadBalance->getUri($this->serviceName);
            $this->zendClient->setUri($uri);
        }
        if ($this->appendPath && strlen($path) > 0 && $this->zendClient->getUri()->getPath() != '/') {
            $path = $this->zendClient->getUri()->getPath() . $path;
        }
        $this->zendClient->getUri()->setPath($path);

        $this->zendClient->getRequest()->getHeaders()->addHeaders($headers);

        if (!$this->zendClient->getRequest()->getHeaders()->has('X-Request-Id')) {
            $this->addRequestId();
        }

        $this->addRequestName($this->serviceName);

        $this->getEventManager()->trigger('request.pre', $this);

        $this->responseTime = 0;

        try {
            $requestTime = microtime(true);

            $zendHttpResponse = $this->zendClient->send();

            $this->responseTime = (float) sprintf('%.2f', (microtime(true) - $requestTime) * 1000);

            $this->addRequestTime($this->responseTime);

            $response = new Response($this->zendClient, $zendHttpResponse, $this->depth);
            $this->reportSuccess();
        } catch (RuntimeException $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), $ex->getCode(), $ex);
        } catch (\Exception $ex) {
            $this->reportFailure();
            $this->getEventManager()->trigger('request.fail', $this, $ex);
            throw new RuntimeException($ex->getMessage(), 500, $ex);
        }

        $this->getEventManager()->trigger('request.post', $this);

        $content = $response->getContent();

        return $content;
    }
private function doRequest ( $ path , $ headers = [ ] ) { if ( ! $ this -> isAvailable ( ) ) { throw new NotAvailableException ( 'Service not available.' ) ; } if ( $ this -> loadBalance !== null ) { $ uri = $ this -> loadBalance -> getUri ( $ this -> serviceName ) ; $ this -> zendClient -> setUri ( $ uri ) ; } if ( $ this -> appendPath && strlen ( $ path ) > 0 && $ this -> zendClient -> getUri ( ) -> getPath ( ) != '/' ) { $ path = $ this -> zendClient -> getUri ( ) -> getPath ( ) . $ path ; } $ this -> zendClient -> getUri ( ) -> setPath ( $ path ) ; $ this -> zendClient -> getRequest ( ) -> getHeaders ( ) -> addHeaders ( $ headers ) ; if ( ! $ this -> zendClient -> getRequest ( ) -> getHeaders ( ) -> has ( 'X-Request-Id' ) ) { $ this -> addRequestId ( ) ; } $ this -> addRequestName ( $ this -> serviceName ) ; $ this -> getEventManager ( ) -> trigger ( 'request.pre' , $ this ) ; $ this -> responseTime = 0 ; try { $ requestTime = microtime ( true ) ; $ zendHttpResponse = $ this -> zendClient -> send ( ) ; $ this -> responseTime = ( float ) sprintf ( '%.2f' , ( microtime ( true ) - $ requestTime ) * 1000 ) ; $ this -> addRequestTime ( $ this -> responseTime ) ; $ response = new Response ( $ this -> zendClient , $ zendHttpResponse , $ this -> depth ) ; $ this -> reportSuccess ( ) ; } catch ( RuntimeException $ ex ) { $ this -> reportFailure ( ) ; $ this -> getEventManager ( ) -> trigger ( 'request.fail' , $ this , $ ex ) ; throw new RuntimeException ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex ) ; } catch ( \ Exception $ ex ) { $ this -> reportFailure ( ) ; $ this -> getEventManager ( ) -> trigger ( 'request.fail' , $ this , $ ex ) ; throw new RuntimeException ( $ ex -> getMessage ( ) , 500 , $ ex ) ; } $ this -> getEventManager ( ) -> trigger ( 'request.post' , $ this ) ; $ content = $ response -> getContent ( ) ; return $ content ; }
Perform the request to api server.

@param $path string                  Example: "/v1/endpoint"
@param array $headers
@return \Hermes\Resource\Resource
@throws NotAvailableException
@throws RuntimeException
Perform the request to api server .