module Workarea decorate Shipping, with: :flow_io do decorated do field :flow_shipping_total, type: Money field :flow_tax_total, type: Money field :delivery_duty, type: String embeds_one :experience, class_name: "Workarea::FlowIo::ExperienceGeo", as: :experienceable embeds_many :flow_price_adjustments, class_name: 'Workarea::PriceAdjustment', extend: PriceAdjustmentExtension end def adjust_flow_pricing(options = {}) flow_price_adjustments.build(options) end # @param ::Io::Flow::V0::Models::DeliveryOption flow_shipping_method def set_flow_shipping!(flow_shipping_method) # clear the default shipping service. self.shipping_service = nil self.delivery_duty = flow_shipping_method.delivered_duty.value self.build_shipping_service(name: flow_shipping_method.tier.name) save! end end end