Class: SolidusAfterpay::ShippingRateBuilderService
- Inherits:
-
BaseService
- Object
- BaseService
- SolidusAfterpay::ShippingRateBuilderService
- Defined in:
- app/services/solidus_afterpay/shipping_rate_builder_service.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(order:) ⇒ ShippingRateBuilderService
constructor
A new instance of ShippingRateBuilderService.
Methods inherited from BaseService
Constructor Details
#initialize(order:) ⇒ ShippingRateBuilderService
Returns a new instance of ShippingRateBuilderService.
5 6 7 8 9 |
# File 'app/services/solidus_afterpay/shipping_rate_builder_service.rb', line 5 def initialize(order:) @order = order super() end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/services/solidus_afterpay/shipping_rate_builder_service.rb', line 11 def call order.shipments.map do |shipment| shipment.shipping_rates.map do |rate| shipping_rate_presenter = SolidusAfterpay::ShippingRatePresenter.new(shipping_rate: rate) { id: rate.id.to_s, name: rate.name, description: rate.display_price, shipping_amount: shipping_rate_presenter.amount_with_taxes.round(4).to_s, currency: rate.currency, order_amount: shipping_rate_presenter.order_amount.round(4).to_s } end end.flatten end |