public function sendRequest($verb, $path, $body = null)
    {
        $this->logger->info('Module: ' . __CLASS__);

        if ($body instanceof Model) {
            $body = $body->toJSON(true);
        }

        $headers = [
            'Authorization' => 'ApiKey ' . $this->config->apiKey,
            'Request-ID' => uniqid('api-request-'),
            'Content-Type' => 'application/json',
        ];

        $this->logger->info('HTTP Request: ' . strtoupper($verb) . ' ' . $this->config->apiEndpoint . $path);
        $this->logger->debug("Request Headers:\n" . print_r($headers, true));

        if (isset($body)) {
            $this->logger->debug("Request Body:\n" . $body);
        }

        $response = $this->http->request(strtoupper($verb), trim($this->config->apiEndpoint . $path), [
            'body' => $body,
            'headers' => $headers
        ]);

        $this->logger->info('HTTP Code: ' . $response->getStatusCode());

        return $response->getBody()->getContents();
    }
public function sendRequest($verb, $path, $body = null)
    {
        $this->logger->info('Module: ' . __CLASS__);

        if ($body instanceof Model) {
            $body = $body->toJSON(true);
        }

        $headers = [
            'Authorization' => 'ApiKey ' . $this->config->apiKey,
            'Request-ID' => uniqid('api-request-'),
            'Content-Type' => 'application/json',
        ];

        $this->logger->info('HTTP Request: ' . strtoupper($verb) . ' ' . $this->config->apiEndpoint . $path);
        $this->logger->debug("Request Headers:\n" . print_r($headers, true));

        if (isset($body)) {
            $this->logger->debug("Request Body:\n" . $body);
        }

        $response = $this->http->request(strtoupper($verb), trim($this->config->apiEndpoint . $path), [
            'body' => $body,
            'headers' => $headers
        ]);

        $this->logger->info('HTTP Code: ' . $response->getStatusCode());

        return $response->getBody()->getContents();
    }
public function sendRequest ( $ verb , $ path , $ body = null ) { $ this -> logger -> info ( 'Module: ' . __CLASS__ ) ; if ( $ body instanceof Model ) { $ body = $ body -> toJSON ( true ) ; } $ headers = [ 'Authorization' => 'ApiKey ' . $ this -> config -> apiKey , 'Request-ID' => uniqid ( 'api-request-' ) , 'Content-Type' => 'application/json' , ] ; $ this -> logger -> info ( 'HTTP Request: ' . strtoupper ( $ verb ) . ' ' . $ this -> config -> apiEndpoint . $ path ) ; $ this -> logger -> debug ( "Request Headers:\n" . print_r ( $ headers , true ) ) ; if ( isset ( $ body ) ) { $ this -> logger -> debug ( "Request Body:\n" . $ body ) ; } $ response = $ this -> http -> request ( strtoupper ( $ verb ) , trim ( $ this -> config -> apiEndpoint . $ path ) , [ 'body' => $ body , 'headers' => $ headers ] ) ; $ this -> logger -> info ( 'HTTP Code: ' . $ response -> getStatusCode ( ) ) ; return $ response -> getBody ( ) -> getContents ( ) ; }
Send the actual request to the connect endpoint
@param string $verb
@param string $path
@param null|Model|string $body
@return string
@throws GuzzleException
Send the actual request to the connect endpoint