Class: Portage::Ucp::FulfillmentMethod

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

Overview

schemas/shopping/types/fulfillment_method.json — shipping or pickup for a subset of line items. The agent submits type/line_item_ids on create; the merchant fills in destinations/groups for the agent to then select selected_destination_id and each group's selected_option_id on update.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type:, line_item_ids:, destinations: [], selected_destination_id: nil, groups: []) ⇒ FulfillmentMethod

Returns a new instance of FulfillmentMethod.



310
311
312
# File 'lib/portage/ucp/value_objects.rb', line 310

def initialize(id:, type:, line_item_ids:, destinations: [], selected_destination_id: nil, groups: [])
  super
end

Instance Attribute Details

#destinationsObject (readonly)

Returns the value of attribute destinations

Returns:

  • (Object)

    the current value of destinations



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def destinations
  @destinations
end

#groupsObject (readonly)

Returns the value of attribute groups

Returns:

  • (Object)

    the current value of groups



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def groups
  @groups
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def id
  @id
end

#line_item_idsObject (readonly)

Returns the value of attribute line_item_ids

Returns:

  • (Object)

    the current value of line_item_ids



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def line_item_ids
  @line_item_ids
end

#selected_destination_idObject (readonly)

Returns the value of attribute selected_destination_id

Returns:

  • (Object)

    the current value of selected_destination_id



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def selected_destination_id
  @selected_destination_id
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



309
310
311
# File 'lib/portage/ucp/value_objects.rb', line 309

def type
  @type
end

Instance Method Details

#to_wire_hObject



314
315
316
317
318
319
320
# File 'lib/portage/ucp/value_objects.rb', line 314

def to_wire_h
  h = { "id" => id, "type" => type, "line_item_ids" => line_item_ids }
  h["destinations"] = destinations.map(&:to_wire_h) unless destinations.empty?
  h["selected_destination_id"] = selected_destination_id if selected_destination_id
  h["groups"] = groups.map(&:to_wire_h) unless groups.empty?
  h
end