Class: OpenReceive::Rates::HttpSimplePriceProvider
- Inherits:
-
Object
- Object
- OpenReceive::Rates::HttpSimplePriceProvider
- Defined in:
- lib/openreceive/rates.rb
Overview
Fetches a Simple Price compatible HTTP endpoint and selects the requested fiat currencies. When timeout_ms is set, a slow endpoint fails within that window so the caller can fall through to another feed.
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#timeout_ms ⇒ Object
readonly
Returns the value of attribute timeout_ms.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#all_btc_fiat_rates ⇒ Object
Returns every well-formed currency the endpoint carries, for caching the whole feed in one read.
- #btc_fiat_rates(currencies) ⇒ Object
-
#initialize(url:, source:, http: nil, timeout_ms: nil) ⇒ HttpSimplePriceProvider
constructor
A new instance of HttpSimplePriceProvider.
Constructor Details
#initialize(url:, source:, http: nil, timeout_ms: nil) ⇒ HttpSimplePriceProvider
Returns a new instance of HttpSimplePriceProvider.
245 246 247 248 249 250 |
# File 'lib/openreceive/rates.rb', line 245 def initialize(url:, source:, http: nil, timeout_ms: nil) @url = url @source = source @http = http @timeout_ms = timeout_ms end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
243 244 245 |
# File 'lib/openreceive/rates.rb', line 243 def source @source end |
#timeout_ms ⇒ Object (readonly)
Returns the value of attribute timeout_ms.
243 244 245 |
# File 'lib/openreceive/rates.rb', line 243 def timeout_ms @timeout_ms end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
243 244 245 |
# File 'lib/openreceive/rates.rb', line 243 def url @url end |
Instance Method Details
#all_btc_fiat_rates ⇒ Object
Returns every well-formed currency the endpoint carries, for caching the whole feed in one read.
258 259 260 |
# File 'lib/openreceive/rates.rb', line 258 def all_btc_fiat_rates Rates.parse_available_simple_price_response(fetch_json) end |
#btc_fiat_rates(currencies) ⇒ Object
252 253 254 |
# File 'lib/openreceive/rates.rb', line 252 def btc_fiat_rates(currencies) Rates.parse_simple_price_response(fetch_json, currencies) end |