Class: Revolut::Api::Utilities
- Inherits:
-
Object
- Object
- Revolut::Api::Utilities
- Defined in:
- lib/revolut/api/utilities.rb
Class Method Summary collapse
- .convert_from_integer_amount(currency, amount) ⇒ Object
-
.convert_to_integer_amount(currency, amount) ⇒ Object
Revolut uses cents, so if you send in $10, multiply by 100 to get Revolut’s internal prices.
- .epoch_to_utc(time) ⇒ Object
- .utc_to_epoch(time) ⇒ Object
Class Method Details
.convert_from_integer_amount(currency, amount) ⇒ Object
20 21 22 23 |
# 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) ⇒ Object
Revolut uses cents, so if you send in $10, multiply by 100 to get Revolut’s internal prices
15 16 17 18 |
# 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) ⇒ Object
6 7 8 |
# File 'lib/revolut/api/utilities.rb', line 6 def epoch_to_utc(time) Time.at(time/::Revolut::Api::Constants::TIME[:epoch_base]).utc end |