Class: Workarea::GlobalE::UpdateOrderDispatchRequest

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/update_order_dispatch_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fulfillment_id, tracking_number: nil) ⇒ UpdateOrderDispatchRequest

Returns a new instance of UpdateOrderDispatchRequest.



6
7
8
9
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 6

def initialize(fulfillment_id, tracking_number: nil)
  @fulfillment_id = fulfillment_id
  @tracking_number = tracking_number
end

Instance Attribute Details

#fulfillment_idObject (readonly)

Returns the value of attribute fulfillment_id.



4
5
6
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 4

def fulfillment_id
  @fulfillment_id
end

#tracking_numberObject (readonly)

Returns the value of attribute tracking_number.



4
5
6
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 4

def tracking_number
  @tracking_number
end

Instance Method Details

#as_json(*args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 11

def as_json(*args)
  {
    OrderId: order_id,
    MerchantOrderId: merchant_order_id,
    DeliveryReferenceNumber: delivery_reference_number,
    IsCompleted: is_completed,
    Parcels: parcels,
    Exceptions: exceptions,
    TrackingDetails: tracking_details
  }
end

#delivery_reference_numberString

Merchant’s internal Delivery Reference Number for this order.

Returns:

  • (String)


46
47
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 46

def delivery_reference_number
end

#exceptionsWorkarea::GlobalE::UpdateOrderDispatchException?

List of UpdateOrderDispatchException objects for this the UpdateOrderDispatchRequest. NOTE either Parcels or Exceptions should be specified. This property is mandatory only if Parcels property has not been specified.



83
84
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 83

def exceptions
end

#is_completedBoolean

Flag to mark orders as “completed” by the merchant. TRUE if order fulfilment has been completed and no more products will be shipped. FALSE if order fulfilment hasn’t been completed yet.

Returns:

  • (Boolean)


55
56
57
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 55

def is_completed
  [:shipped, :canceled].include? fulfilment.status
end

#merchant_order_idString

Order unique identifier on the Merchant’s site. NOTE either OrderID or MerchantOrderID should be specified. This property is mandatory only if OrderID property has not been specified.

Returns:

  • (String)


39
40
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 39

def merchant_order_id
end

#order_idString

Global-e order unique identifier. NOTE either OrderID or MerchantOrderID should be specified. This property is mandatory only if MerchantOrderID property has not been specified.

Returns:

  • (String)


29
30
31
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 29

def order_id
  order.global_e_id
end

#parcelsArray<Workarea::GlobalE::Parcel>, Nil

List of Parcel object for this UpdateOrderDispatchRequest. NOTE either Parcels or Exceptions should be specified. This property is mandatory only if Exceptions property has not been specified.

Returns:



65
66
67
68
69
70
71
72
73
74
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 65

def parcels
  return unless tracking_number.present?

  @parcels ||= Array.wrap(fulfilment.find_package(tracking_number)).map do |package|
    GlobalE::Parcel.new(
      fulfilment,
      Storefront::PackageViewModel.wrap(package, order: order)
    )
  end
end

#tracking_detailsWorkarea::GlobalE::TrackingDetails nil

Tracking information on order level of the parcel in case the merchant does the shipping by itself.



91
92
93
94
95
# File 'app/services/workarea/global_e/update_order_dispatch_request.rb', line 91

def tracking_details
  return unless tracking_number.present?

  TrackingDetails.new(tracking_number: tracking_number)
end