From 1360eb9befd50b797239bb12e1b0373da344eab1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 13:40:28 +0000 Subject: [PATCH 1/2] Initial plan From 83cd894502189095b049ae8d25a3526e08785422 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 13:43:48 +0000 Subject: [PATCH 2/2] docs: add comprehensive documentation to ApiClient class Co-authored-by: bougyman <6848+bougyman@users.noreply.github.com> --- lib/kalshi/api_client.rb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/kalshi/api_client.rb b/lib/kalshi/api_client.rb index b8aba76..a1e03c9 100644 --- a/lib/kalshi/api_client.rb +++ b/lib/kalshi/api_client.rb @@ -2,18 +2,53 @@ module Rubyists module Kalshi - # API Client Base Class + # Base class for API client wrappers that automatically configure URL prefixes + # + # This class provides a foundation for building API clients that need to + # communicate with different API namespaces. It automatically extracts the + # prefix from the module hierarchy and applies it to the underlying HTTP client. + # + # @example Using ApiClient with a Search namespace + # # For Rubyists::Kalshi::Search::Client, the prefix will be "search" + # class Search::Client < ApiClient + # # API calls will automatically use /search/ prefix + # end + # + # @example Overriding the automatic prefix + # class CustomClient < ApiClient + # self.prefix = 'custom_api' + # end class ApiClient attr_reader :client + # Automatically extract the URL prefix from the module hierarchy + # + # The prefix is derived by taking the second-to-last component of the + # fully qualified class name and converting it to lowercase. For example: + # - Rubyists::Kalshi::Search::Client => "search" + # - Rubyists::Kalshi::Market::Client => "market" + # + # @return [String] the URL prefix for API calls def self.prefix @prefix ||= to_s.split('::')[-2].downcase end + # Set a custom URL prefix, overriding the automatic extraction + # + # @param value [String] the custom prefix to use for API calls + # + # @return [String] the prefix value def self.prefix=(value) # rubocop:disable Style/TrivialAccessors @prefix = value end + # Initialize the API client with the given HTTP client + # + # Automatically configures the client's prefix based on the class hierarchy + # + # @param client [Client] the Kalshi HTTP client instance + # + # @return [void] def initialize(client) @client = client client.prefix = self.class.prefix