Class: FriendlyShipping::Services::UpsJson::ParseRateModifierHash
- Inherits:
-
Object
- Object
- FriendlyShipping::Services::UpsJson::ParseRateModifierHash
- Defined in:
- lib/friendly_shipping/services/ups_json/parse_rate_modifier_hash.rb
Class Method Summary collapse
-
.call(rate_modifier, currency_code:) ⇒ Array
The label and the amount of the rate modifier.
Class Method Details
.call(rate_modifier, currency_code:) ⇒ Array
Returns The label and the amount of the rate modifier.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/friendly_shipping/services/ups_json/parse_rate_modifier_hash.rb', line 10 def self.call(rate_modifier, currency_code:) return unless rate_modifier amount = rate_modifier['Amount'].to_d return if amount.zero? currency = Money::Currency.new(currency_code) amount = Money.new(amount * currency.subunit_to_unit, currency) modifier_type = rate_modifier['ModifierType'] modifier_description = rate_modifier['ModifierDesc'] label = "#{modifier_type} (#{modifier_description})" [label, amount] end |