public function sendRequest(ApiKey $apiKey, RestRequest $request)
    {
        $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData()));

        $client = new Client([
            'base_uri' => $request->getHost()
        ]);
        
        $args = [
            'auth' => [$apiKey->getPublicKey(), $hmac],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ];
        
        if ($request->getRequestMethod() === 'POST') {
            $args['form_params'] = $request->getPostData();
        } else {
            $args['query'] = $request->getQueryData();
        }
        
        try {
            $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args);
        } catch (RequestException $e) {
            if (!$e->hasResponse()) {
                throw new Exception('Cannot send REST request.', 0, $e);
            }
            
            $responseRaw = $e->getResponse();
        }
        
        return $this->prepareResponse($responseRaw, $request);
    }
public function sendRequest(ApiKey $apiKey, RestRequest $request)
    {
        $hmac = $this->generateHmac($apiKey->getPrivateKey(), $request->getEndpoint(), array_merge($request->getQueryData(), $request->getPostData()));

        $client = new Client([
            'base_uri' => $request->getHost()
        ]);
        
        $args = [
            'auth' => [$apiKey->getPublicKey(), $hmac],
            'headers' => [
                'Accept' => 'application/json'
            ]
        ];
        
        if ($request->getRequestMethod() === 'POST') {
            $args['form_params'] = $request->getPostData();
        } else {
            $args['query'] = $request->getQueryData();
        }
        
        try {
            $responseRaw = $client->request($request->getRequestMethod(), $request->getEndpoint(), $args);
        } catch (RequestException $e) {
            if (!$e->hasResponse()) {
                throw new Exception('Cannot send REST request.', 0, $e);
            }
            
            $responseRaw = $e->getResponse();
        }
        
        return $this->prepareResponse($responseRaw, $request);
    }
public function sendRequest ( ApiKey $ apiKey , RestRequest $ request ) { $ hmac = $ this -> generateHmac ( $ apiKey -> getPrivateKey ( ) , $ request -> getEndpoint ( ) , array_merge ( $ request -> getQueryData ( ) , $ request -> getPostData ( ) ) ) ; $ client = new Client ( [ 'base_uri' => $ request -> getHost ( ) ] ) ; $ args = [ 'auth' => [ $ apiKey -> getPublicKey ( ) , $ hmac ] , 'headers' => [ 'Accept' => 'application/json' ] ] ; if ( $ request -> getRequestMethod ( ) === 'POST' ) { $ args [ 'form_params' ] = $ request -> getPostData ( ) ; } else { $ args [ 'query' ] = $ request -> getQueryData ( ) ; } try { $ responseRaw = $ client -> request ( $ request -> getRequestMethod ( ) , $ request -> getEndpoint ( ) , $ args ) ; } catch ( RequestException $ e ) { if ( ! $ e -> hasResponse ( ) ) { throw new Exception ( 'Cannot send REST request.' , 0 , $ e ) ; } $ responseRaw = $ e -> getResponse ( ) ; } return $ this -> prepareResponse ( $ responseRaw , $ request ) ; }
Sends the RestRequest to the endpoint

@access public
@param \Zepi\Api\AccessControl\Entity\ApiKey $apiKey
@param \Zepi\Api\Rest\Entity\Request $request
@return \Zepi\Api\Rest\Entity\Response

@throws \Zepi\Api\Rest\Exception Cannot send REST request.
Sends the RestRequest to the endpoint