Class: Afterpay::Utils::Money
- Inherits:
-
Object
- Object
- Afterpay::Utils::Money
- Defined in:
- lib/afterpay/utils/money.rb
Class Method Summary collapse
-
.api_hash(money) ⇒ Object
Converts <oney to API compatible hash format.
-
.from_response(response) ⇒ Money
Converts Afterpay response to ‘Money`.
Class Method Details
.api_hash(money) ⇒ Object
Converts <oney to API compatible hash format
18 19 20 21 22 23 |
# File 'lib/afterpay/utils/money.rb', line 18 def self.api_hash(money) { amount: money.dollars.to_f, currency: money.currency.iso_code } end |
.from_response(response) ⇒ Money
Converts Afterpay response to ‘Money`
8 9 10 11 12 13 14 15 |
# File 'lib/afterpay/utils/money.rb', line 8 def self.from_response(response) return nil if response.nil? ::Money.from_amount( response[:amount].to_f, response[:currency] ) end |