public function makeRequest($method, $endpoint, $body = [], $asArray = true)
    {
        try {
            list($rawBody, $httpStatusCode, $httpHeader) = $this->getHttpClient()->request(
                $method,
                $this->makeAbsUrl($endpoint),
                ['api_key' => $this->apiKey],
                $body
            );

            $array = json_decode($rawBody, true);
        } catch (\Exception $e) {
            throw new ApiError($e->getMessage(), $body);
        }

        if ($asArray) {
            return $array;
        }
        return [$rawBody, $httpStatusCode, $httpHeader];
    }
public function makeRequest($method, $endpoint, $body = [], $asArray = true)
    {
        try {
            list($rawBody, $httpStatusCode, $httpHeader) = $this->getHttpClient()->request(
                $method,
                $this->makeAbsUrl($endpoint),
                ['api_key' => $this->apiKey],
                $body
            );

            $array = json_decode($rawBody, true);
        } catch (\Exception $e) {
            throw new ApiError($e->getMessage(), $body);
        }

        if ($asArray) {
            return $array;
        }
        return [$rawBody, $httpStatusCode, $httpHeader];
    }
public function makeRequest ( $ method , $ endpoint , $ body = [ ] , $ asArray = true ) { try { list ( $ rawBody , $ httpStatusCode , $ httpHeader ) = $ this -> getHttpClient ( ) -> request ( $ method , $ this -> makeAbsUrl ( $ endpoint ) , [ 'api_key' => $ this -> apiKey ] , $ body ) ; $ array = json_decode ( $ rawBody , true ) ; } catch ( \ Exception $ e ) { throw new ApiError ( $ e -> getMessage ( ) , $ body ) ; } if ( $ asArray ) { return $ array ; } return [ $ rawBody , $ httpStatusCode , $ httpHeader ] ; }
Make the API call and return the response.

@param string $method    Method to use for given endpoint
@param string $endpoint  Endpoint to hit on API
@param array $body       Body content of the request as array
@param bool $asArray     To know if we return an array or ResponseInterface
@return array|ResponseInterface
@throws ApiError
Make the API call and return the response .