Class: Stellwerk::ApiClient
- Inherits:
-
Object
- Object
- Stellwerk::ApiClient
- Defined in:
- lib/stellwerk/api_client.rb
Overview
HTTP client wrapper for Stellwerk API communication
Uses net/http from Ruby stdlib for zero external dependencies. Handles authentication, retries, timeouts, and JSON parsing.
Constant Summary collapse
- DEFAULT_TIMEOUT =
Default timeout for HTTP requests (seconds)
10- MAX_ATTEMPTS =
Maximum total attempts for transient failures (initial + retries)
3- RETRY_DELAY =
Delay between retries (seconds)
1
Instance Method Summary collapse
-
#get(path) ⇒ Hash
Make a GET request.
-
#initialize(api_url:, api_key:, timeout: DEFAULT_TIMEOUT, verify_ssl: true) ⇒ ApiClient
constructor
A new instance of ApiClient.
-
#post(path, body = {}) ⇒ Hash
Make a POST request.
Constructor Details
#initialize(api_url:, api_key:, timeout: DEFAULT_TIMEOUT, verify_ssl: true) ⇒ ApiClient
Returns a new instance of ApiClient.
28 29 30 31 32 33 |
# File 'lib/stellwerk/api_client.rb', line 28 def initialize(api_url:, api_key:, timeout: DEFAULT_TIMEOUT, verify_ssl: true) @api_url = api_url.chomp("/") @api_key = api_key @timeout = timeout @verify_ssl = verify_ssl end |
Instance Method Details
#get(path) ⇒ Hash
Make a GET request
40 41 42 |
# File 'lib/stellwerk/api_client.rb', line 40 def get(path) request(:get, path) end |
#post(path, body = {}) ⇒ Hash
Make a POST request
50 51 52 |
# File 'lib/stellwerk/api_client.rb', line 50 def post(path, body = {}) request(:post, path, body) end |