class Revolut::Api::Utilities
Public Class Methods
convert_from_integer_amount(currency, amount)
click to toggle source
# File lib/revolut/api/utilities.rb, line 20 def convert_from_integer_amount(currency, amount) sub_unit = ::Revolut::Api::Constants::CRYPTOS.include?(currency) ? ::Revolut::Api::Constants::BASE_UNITS[:crypto] : ::Revolut::Api::Constants::BASE_UNITS[:fiat] (amount.to_f / sub_unit) end
convert_to_integer_amount(currency, amount)
click to toggle source
Revolut
uses cents, so if you send in $10, multiply by 100 to get Revolut's internal prices
# File lib/revolut/api/utilities.rb, line 15 def convert_to_integer_amount(currency, amount) sub_unit = ::Revolut::Api::Constants::CRYPTOS.include?(currency) ? ::Revolut::Api::Constants::BASE_UNITS[:crypto] : ::Revolut::Api::Constants::BASE_UNITS[:fiat] (amount.to_f * sub_unit).round(0).to_i end
epoch_to_utc(time)
click to toggle source
# File lib/revolut/api/utilities.rb, line 6 def epoch_to_utc(time) Time.at(time/::Revolut::Api::Constants::TIME[:epoch_base]).utc end
utc_to_epoch(time)
click to toggle source
# File lib/revolut/api/utilities.rb, line 10 def utc_to_epoch(time) time.to_i * ::Revolut::Api::Constants::TIME[:epoch_base] end