Class: Strava::Web::Client
- Inherits:
-
Object
- Object
- Strava::Web::Client
- Includes:
- Connection, Request
- Defined in:
- lib/strava/web/client.rb
Overview
Base web client class for making HTTP requests to Strava APIs.
This class provides the foundation for all Strava client implementations (API, OAuth, and Webhooks clients). It handles HTTP connection management, request execution, and configuration management.
The client includes mixins for connection handling and HTTP request methods, and manages configuration attributes like endpoint URLs, user agents, and authentication tokens.
Direct Known Subclasses
Class Method Summary collapse
-
.config ⇒ Module
Returns the current configuration.
-
.configure {|Config| ... } ⇒ Module
Configure the client with a block or return the configuration.
Instance Method Summary collapse
-
#endpoint ⇒ String
Returns the API endpoint URL for this client.
-
#initialize(options = {}) ⇒ Client
constructor
Initialize a new client instance.
-
#parse_args(id_or_options, options = {}) ⇒ Array<(String, Hash)>
Parse method arguments that can be either (id, options) or (options).
Methods included from Request
Constructor Details
Class Method Details
.config ⇒ Module
Returns the current configuration.
73 74 75 |
# File 'lib/strava/web/client.rb', line 73 def config Config end |
Instance Method Details
#endpoint ⇒ String
This method must be implemented by subclasses
Returns the API endpoint URL for this client.
48 49 50 |
# File 'lib/strava/web/client.rb', line 48 def endpoint raise NotImplementedError end |
#parse_args(id_or_options, options = {}) ⇒ Array<(String, Hash)>
Parse method arguments that can be either (id, options) or (options).
This helper method standardizes the common pattern where Strava API methods accept either a resource ID as the first parameter followed by an options hash, or just an options hash containing an :id key.
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/strava/web/client.rb', line 100 def parse_args(, = {}) if .is_a?(Hash) raise ArgumentError, 'Required argument :id missing' if [:id].nil? [[:id], .except(:id)] else raise ArgumentError, 'Required argument :id missing' if .nil? [, ] end end |