Class: Polygonio::Rest::Client
- Inherits:
-
Object
- Object
- Polygonio::Rest::Client
- Defined in:
- lib/polygonio/rest/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.polygon.io/"
- RETRY_OPTIONS =
{ max: 2, interval: 0.05, interval_randomness: 0.5, backoff_factor: 2, exceptions: [Faraday::ConnectionFailed].concat(Faraday::Request::Retry::DEFAULT_EXCEPTIONS) }.freeze
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #crypto ⇒ Object
- #forex ⇒ Object
-
#initialize(api_key, &block) ⇒ Client
constructor
A new instance of Client.
- #reference ⇒ Object
- #request ⇒ Object
- #stocks ⇒ Object
Constructor Details
Instance Attribute Details
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
10 11 12 |
# File 'lib/polygonio/rest/client.rb', line 10 def api_key @api_key end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/polygonio/rest/client.rb', line 10 def url @url end |
Instance Method Details
#crypto ⇒ Object
54 55 56 |
# File 'lib/polygonio/rest/client.rb', line 54 def crypto Rest::Crypto.new(self) end |
#forex ⇒ Object
50 51 52 |
# File 'lib/polygonio/rest/client.rb', line 50 def forex Rest::Forex.new(self) end |
#reference ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/polygonio/rest/client.rb', line 37 def reference Struct::Reference.new( Rest::Reference::Locales.new(self), Rest::Reference::Markets.new(self), Rest::Reference::Stocks.new(self), Rest::Reference::Tickers.new(self) ) end |
#request ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/polygonio/rest/client.rb', line 26 def request Faraday.new(url: "#{url}?apiKey=#{api_key}") do |builder| builder.request :retry, RETRY_OPTIONS builder.use ErrorMiddleware @request_builder&.call(builder) builder.request :json builder.response :oj builder.adapter Faraday.default_adapter end end |