Class: VistarClient::Connection Private
- Inherits:
-
Object
- Object
- VistarClient::Connection
- Defined in:
- lib/vistar_client/connection.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Manages HTTP connections to the Vistar Media API.
This class encapsulates Faraday connection configuration including:
-
JSON request/response handling
-
Automatic retry logic for transient failures
-
Custom error handling middleware
-
Request/response logging (when VISTAR_DEBUG is set)
-
Timeout configuration
-
Authentication headers
Instance Attribute Summary collapse
-
#api_base_url ⇒ String
readonly
private
The base URL for the API.
-
#api_key ⇒ String
readonly
private
The API key for authentication.
-
#timeout ⇒ Integer
readonly
private
The timeout for HTTP requests in seconds.
Instance Method Summary collapse
-
#get ⇒ Faraday::Connection
(also: #to_faraday)
private
Get or create a Faraday connection instance.
-
#get_request(path, params = {}) ⇒ Faraday::Response
private
Make a GET request.
-
#initialize(api_key:, api_base_url:, timeout:) ⇒ Connection
constructor
private
Initialize a new HTTP connection manager.
-
#method_missing(method) ⇒ Object
private
Delegate method_missing to the underlying Faraday connection to maintain backward compatibility with tests.
-
#post(path, payload) ⇒ Faraday::Response
private
Make a POST request.
-
#respond_to_missing?(method, include_private = false) ⇒ Boolean
private
Check if the connection responds to a method.
Constructor Details
#initialize(api_key:, api_base_url:, timeout:) ⇒ Connection
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new HTTP connection manager.
34 35 36 37 38 |
# File 'lib/vistar_client/connection.rb', line 34 def initialize(api_key:, api_base_url:, timeout:) @api_key = api_key @api_base_url = api_base_url @timeout = timeout end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Delegate method_missing to the underlying Faraday connection to maintain backward compatibility with tests.
74 75 76 77 78 79 80 |
# File 'lib/vistar_client/connection.rb', line 74 def method_missing(method, ...) if get.respond_to?(method) get.public_send(method, ...) else super end end |
Instance Attribute Details
#api_base_url ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the base URL for the API.
24 25 26 |
# File 'lib/vistar_client/connection.rb', line 24 def api_base_url @api_base_url end |
#api_key ⇒ String (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the API key for authentication.
21 22 23 |
# File 'lib/vistar_client/connection.rb', line 21 def api_key @api_key end |
#timeout ⇒ Integer (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns the timeout for HTTP requests in seconds.
27 28 29 |
# File 'lib/vistar_client/connection.rb', line 27 def timeout @timeout end |
Instance Method Details
#get ⇒ Faraday::Connection Also known as: to_faraday
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get or create a Faraday connection instance.
The connection is cached and reused for subsequent requests.
45 46 47 |
# File 'lib/vistar_client/connection.rb', line 45 def get @get ||= build_connection end |
#get_request(path, params = {}) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Make a GET request.
64 65 66 |
# File 'lib/vistar_client/connection.rb', line 64 def get_request(path, params = {}) get.get(path, params) end |
#post(path, payload) ⇒ Faraday::Response
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Make a POST request.
55 56 57 |
# File 'lib/vistar_client/connection.rb', line 55 def post(path, payload) get.post(path, payload) end |
#respond_to_missing?(method, include_private = false) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the connection responds to a method.
87 88 89 |
# File 'lib/vistar_client/connection.rb', line 87 def respond_to_missing?(method, include_private = false) get.respond_to?(method, include_private) || super end |