Class: Rubyists::Kalshi::ApiClient
- Inherits:
-
Object
- Object
- Rubyists::Kalshi::ApiClient
- Defined in:
- lib/kalshi/api_client.rb
Overview
Base class for API client wrappers that automatically configure URL prefixes
Direct Known Subclasses
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
-
.prefix ⇒ String
Automatically extract the URL prefix from the module hierarchy.
-
.prefix=(value) ⇒ Object
Set a custom URL prefix for API calls, for overriding the default behavior.
Instance Method Summary collapse
-
#initialize(client) ⇒ void
constructor
Initialize the ApiClient with a given client instance.
Constructor Details
#initialize(client) ⇒ void
Initialize the ApiClient with a given client instance
42 43 44 45 |
# File 'lib/kalshi/api_client.rb', line 42 def initialize(client) @client = client client.prefix = self.class.prefix end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
18 19 20 |
# File 'lib/kalshi/api_client.rb', line 18 def client @client end |
Class Method Details
.prefix ⇒ String
28 29 30 |
# File 'lib/kalshi/api_client.rb', line 28 def self.prefix @prefix ||= to_s.split('::')[-2].downcase end |
.prefix=(value) ⇒ Object
Set a custom URL prefix for API calls, for overriding the default behavior
33 34 35 |
# File 'lib/kalshi/api_client.rb', line 33 def self.prefix=(value) # rubocop:disable Style/TrivialAccessors @prefix = value end |