Class: Money::Bank::Uphold
- Inherits:
-
VariableExchange
- Object
- VariableExchange
- Money::Bank::Uphold
- Defined in:
- lib/money/bank/uphold.rb
Constant Summary collapse
- UPHOLD_TICKERS_URL =
"https://api.uphold.com/v0/ticker".freeze
- UPHOLD_BASE_CURRENCY =
"USD".freeze
Instance Attribute Summary collapse
-
#rates_expire_at ⇒ Object
readonly
Rates expiration time.
-
#tickers ⇒ Object
readonly
Parsed UpholdBank result as a Hash.
-
#ttl_in_seconds ⇒ Object
Seconds after which the current rates are automatically expired.
Instance Method Summary collapse
- #get_rate(iso_from, iso_to, opts = {}) ⇒ Object
-
#initialize(*args, &block) ⇒ Uphold
constructor
A new instance of Uphold.
- #original_get_rate ⇒ Object
-
#update_rates ⇒ Object
Update all rates from UpholdBank JSON.
Constructor Details
#initialize(*args, &block) ⇒ Uphold
Returns a new instance of Uphold.
19 20 21 22 |
# File 'lib/money/bank/uphold.rb', line 19 def initialize(*args, &block) super ttl_in_seconds = 3600 # 1 hour end |
Instance Attribute Details
#rates_expire_at ⇒ Object (readonly)
Rates expiration time
17 18 19 |
# File 'lib/money/bank/uphold.rb', line 17 def rates_expire_at @rates_expire_at end |
#tickers ⇒ Object (readonly)
Parsed UpholdBank result as a Hash
14 15 16 |
# File 'lib/money/bank/uphold.rb', line 14 def tickers @tickers end |
#ttl_in_seconds ⇒ Object
Seconds after which the current rates are automatically expired
11 12 13 |
# File 'lib/money/bank/uphold.rb', line 11 def ttl_in_seconds @ttl_in_seconds end |
Instance Method Details
#get_rate(iso_from, iso_to, opts = {}) ⇒ Object
37 38 39 40 41 |
# File 'lib/money/bank/uphold.rb', line 37 def get_rate(iso_from, iso_to, opts = {}) update_rates_if_expired super || get_indirect_rate(iso_from, iso_to, opts) end |
#original_get_rate ⇒ Object
35 |
# File 'lib/money/bank/uphold.rb', line 35 alias original_get_rate get_rate |
#update_rates ⇒ Object
Update all rates from UpholdBank JSON
25 26 27 28 29 30 31 32 33 |
# File 'lib/money/bank/uphold.rb', line 25 def update_rates # clear all existing rates, even inferred ones store.each_rate do |iso_from, iso_to, _rate| add_rate(iso_from, iso_to, nil) end exchange_rates.each do |ticker| add_exchange_rates_from_ticker(ticker) end end |