Class: Workarea::GlobalE::Parcel
- Inherits:
-
Object
- Object
- Workarea::GlobalE::Parcel
- Defined in:
- app/services/workarea/global_e/parcel.rb
Instance Attribute Summary collapse
-
#fulfillment ⇒ Object
readonly
Returns the value of attribute fulfillment.
-
#package ⇒ Object
readonly
Returns the value of attribute package.
Instance Method Summary collapse
- #as_json ⇒ Object
-
#initialize(fulfillment, package) ⇒ Parcel
constructor
A new instance of Parcel.
-
#parcel_code ⇒ String
Code used to identify the Parcel on the Merchant’s site.
-
#products ⇒ Hash
List of products contained in the parcel (for each Product object the following fields are relevant when used in Parcel class: ProductCode, CartItemId, DeliveryQuantity).
-
#tracking_details ⇒ Workarea::GlobalE::TrackingDetails
Tracking information about the order/parcel.
Constructor Details
#initialize(fulfillment, package) ⇒ Parcel
Returns a new instance of Parcel.
6 7 8 9 |
# File 'app/services/workarea/global_e/parcel.rb', line 6 def initialize(fulfillment, package) @fulfillment = fulfillment @package = package end |
Instance Attribute Details
#fulfillment ⇒ Object (readonly)
Returns the value of attribute fulfillment.
4 5 6 |
# File 'app/services/workarea/global_e/parcel.rb', line 4 def fulfillment @fulfillment end |
#package ⇒ Object (readonly)
Returns the value of attribute package.
4 5 6 |
# File 'app/services/workarea/global_e/parcel.rb', line 4 def package @package end |
Instance Method Details
#as_json ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/services/workarea/global_e/parcel.rb', line 11 def as_json(*) { ParcelCode: parcel_code, Products: products, TrackingDetails: tracking_details } end |
#parcel_code ⇒ String
Code used to identify the Parcel on the Merchant’s site
23 24 25 |
# File 'app/services/workarea/global_e/parcel.rb', line 23 def parcel_code package.tracking_number end |
#products ⇒ Hash
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).
35 36 37 38 39 40 41 42 |
# File 'app/services/workarea/global_e/parcel.rb', line 35 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_details ⇒ Workarea::GlobalE::TrackingDetails
Tracking information about the order/parcel.
48 49 50 |
# File 'app/services/workarea/global_e/parcel.rb', line 48 def tracking_details TrackingDetails.new(tracking_number: package.tracking_number) end |