Sha256: 24fa822b057ebee7b34f02935f85e47cac65b1061a4f3613018db344f9dd59e2
Contents?: true
Size: 1.45 KB
Versions: 2
Compression:
Stored size: 1.45 KB
Contents
module Workarea module GlobalE class Parcel attr_reader :fulfillment, :package def initialize(fulfillment, package) @fulfillment = fulfillment @package = package end def as_json(*) { ParcelCode: parcel_code, Products: products, TrackingDetails: tracking_details } end # Code used to identify the Parcel on the Merchant’s site # # @return [String] # def parcel_code package.tracking_number end # List of products contained in the parcel (for each Product object the # following fields are relevant when used in Parcel class: ProductCode, # CartItemId, DeliveryQuantity). Products list is applicable only when # including the list of products in each parcel is mandatory (such as in # UpdateParcelDispatch method). # # @return [Hash] # def products @products ||= package.items.map do |fulfillment_item| GlobalE::Product.from_order_item( fulfillment_item, delivery_quantity: fulfillment_item.quantity ).as_json.slice(:CartItemId, :DeliveryQuantity, :ProductCode) end end # Tracking information about the order/parcel. # # @return [Workarea::GlobalE::TrackingDetails] # def tracking_details TrackingDetails.new(tracking_number: package.tracking_number) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
workarea-global_e-1.3.0 | app/services/workarea/global_e/parcel.rb |
workarea-global_e-1.2.1 | app/services/workarea/global_e/parcel.rb |