Class: Rubyists::Domeapi::Client
- Inherits:
-
Object
- Object
- Rubyists::Domeapi::Client
- Includes:
- SemanticLogger::Loggable
- Defined in:
- lib/domeapi/client.rb
Overview
HTTP Client for Domeapi API
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
Instance Method Summary collapse
- #get(path, params: {}) ⇒ Object
-
#initialize(api_key: Domeapi.config.api_key, base_url: Domeapi.config.base_url) ⇒ Client
constructor
A new instance of Client.
- #polymarket ⇒ Object
Constructor Details
#initialize(api_key: Domeapi.config.api_key, base_url: Domeapi.config.base_url) ⇒ Client
Returns a new instance of Client.
15 16 17 18 19 20 |
# File 'lib/domeapi/client.rb', line 15 def initialize(api_key: Domeapi.config.api_key, base_url: Domeapi.config.base_url) @base_url = base_url @http = HTTPX.plugin(:persistent) .plugin(:rate_limiter) .with(origin: base_url, headers: { 'Authorization' => "Bearer #{api_key}" }) end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
12 13 14 |
# File 'lib/domeapi/client.rb', line 12 def base_url @base_url end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
12 13 14 |
# File 'lib/domeapi/client.rb', line 12 def http @http end |
#prefix ⇒ Object
Returns the value of attribute prefix.
13 14 15 |
# File 'lib/domeapi/client.rb', line 13 def prefix @prefix end |
Instance Method Details
#get(path, params: {}) ⇒ Object
22 23 24 25 |
# File 'lib/domeapi/client.rb', line 22 def get(path, params: {}) response = @http.get(full_url(path), params:) handle_response(response) end |
#polymarket ⇒ Object
27 28 29 |
# File 'lib/domeapi/client.rb', line 27 def polymarket @polymarket ||= Polymarket::Client.new(clone) end |