Class: Portage::Ucp::CheckoutFulfillment

Inherits:
Data
  • Object
show all
Defined in:
lib/portage/ucp/value_objects.rb

Overview

schemas/shopping/fulfillment.json#/$defs/dev.ucp.shopping.fulfillment — the Checkout-level container. Named CheckoutFulfillment (not Fulfillment, already taken by Order's post-purchase expectations/ events container below) to keep the pre-purchase shipping-selection extension and the post-purchase delivery-tracking extension distinct. The member is shipping_methods, not the wire key methods — a bare :methods Data.define member would shadow Kernel#methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shipping_methods: [], available_methods: []) ⇒ CheckoutFulfillment

Returns a new instance of CheckoutFulfillment.



345
# File 'lib/portage/ucp/value_objects.rb', line 345

def initialize(shipping_methods: [], available_methods: []) = super

Instance Attribute Details

#available_methodsObject (readonly)

Returns the value of attribute available_methods

Returns:

  • (Object)

    the current value of available_methods



344
345
346
# File 'lib/portage/ucp/value_objects.rb', line 344

def available_methods
  @available_methods
end

#shipping_methodsObject (readonly)

Returns the value of attribute shipping_methods

Returns:

  • (Object)

    the current value of shipping_methods



344
345
346
# File 'lib/portage/ucp/value_objects.rb', line 344

def shipping_methods
  @shipping_methods
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


347
# File 'lib/portage/ucp/value_objects.rb', line 347

def empty? = shipping_methods.empty? && available_methods.empty?

#to_wire_hObject



349
350
351
352
353
354
# File 'lib/portage/ucp/value_objects.rb', line 349

def to_wire_h
  h = {}
  h["methods"] = shipping_methods.map(&:to_wire_h) unless shipping_methods.empty?
  h["available_methods"] = available_methods.map(&:to_wire_h) unless available_methods.empty?
  h
end