Class: ApiWrapper::HttpClient::FaradayClient

Inherits:
BaseClient
  • Object
show all
Defined in:
lib/api_wrapper/http_client/faraday_client.rb

Overview

FaradayClient class is responsible for making HTTP requests using Faraday.

Instance Method Summary collapse

Methods inherited from BaseClient

#initialize

Constructor Details

This class inherits a constructor from ApiWrapper::HttpClient::BaseClient

Instance Method Details

#get(endpoint, force_refresh: false) ⇒ Faraday::Response

Sends a GET request to the specified endpoint.

Parameters:

  • endpoint (String)

    The endpoint to send the request to.

  • force_refresh (Boolean) (defaults to: false)

    Whether to force a cache refresh.

Returns:

  • (Faraday::Response)

    The response object.



17
18
19
20
21
22
23
24
# File 'lib/api_wrapper/http_client/faraday_client.rb', line 17

def get(endpoint, force_refresh: false)
  # Use the cache policy to determine whether to fetch from cache or refresh.
  @cache_policy.fetch(endpoint, force_refresh:) do
    handle_connection(endpoint) do |connection|
      connection.get(endpoint)
    end
  end
end