Class: PetstoreApiClient::Client
- Inherits:
-
Object
- Object
- PetstoreApiClient::Client
- Includes:
- Connection, Request
- Defined in:
- lib/petstore_api_client/client.rb
Overview
Base HTTP client for Petstore API
Provides low-level HTTP communication with the Petstore API. This class includes Connection and Request modules to handle connection management and HTTP request execution.
Most users should use the higher-level PetClient or StoreClient instead of using this class directly.
Direct Known Subclasses
PetstoreApiClient::Clients::PetClient, PetstoreApiClient::Clients::StoreClient
Instance Attribute Summary collapse
- #configuration ⇒ Object readonly
Instance Method Summary collapse
-
#configure {|configuration| ... } ⇒ Client
Configure the client via block.
-
#initialize(config = nil) ⇒ Client
constructor
Initialize a new HTTP client.
Methods included from Request
Constructor Details
#initialize(config = nil) ⇒ Client
Initialize a new HTTP client
Creates a new client instance with the provided configuration. If no configuration is provided, uses default configuration. Validates configuration before creating the client.
59 60 61 62 |
# File 'lib/petstore_api_client/client.rb', line 59 def initialize(config = nil) @configuration = config || Configuration.new @configuration.validate! end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
38 39 40 |
# File 'lib/petstore_api_client/client.rb', line 38 def configuration @configuration end |
Instance Method Details
#configure {|configuration| ... } ⇒ Client
Configure the client via block
Yields the configuration object to the block for modification. Automatically resets the connection after configuration changes to ensure new settings are applied.
81 82 83 84 85 |
# File 'lib/petstore_api_client/client.rb', line 81 def configure yield(configuration) if block_given? reset_connection! # Need to reset when config changes self end |