Class: Portage::Ucp::FulfillmentOption

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

Overview

schemas/shopping/types/fulfillment_option.json — a single priced choice within a FulfillmentGroup (e.g. "Standard Shipping $5", "Express $15").

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, title:, totals:, description: nil, carrier: nil, earliest_fulfillment_time: nil, latest_fulfillment_time: nil) ⇒ FulfillmentOption

Returns a new instance of FulfillmentOption.



277
278
279
280
# File 'lib/portage/ucp/value_objects.rb', line 277

def initialize(id:, title:, totals:, description: nil, carrier: nil, earliest_fulfillment_time: nil,
               latest_fulfillment_time: nil)
  super
end

Instance Attribute Details

#carrierObject (readonly)

Returns the value of attribute carrier

Returns:

  • (Object)

    the current value of carrier



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def carrier
  @carrier
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def description
  @description
end

#earliest_fulfillment_timeObject (readonly)

Returns the value of attribute earliest_fulfillment_time

Returns:

  • (Object)

    the current value of earliest_fulfillment_time



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def earliest_fulfillment_time
  @earliest_fulfillment_time
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def id
  @id
end

#latest_fulfillment_timeObject (readonly)

Returns the value of attribute latest_fulfillment_time

Returns:

  • (Object)

    the current value of latest_fulfillment_time



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def latest_fulfillment_time
  @latest_fulfillment_time
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def title
  @title
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



275
276
277
# File 'lib/portage/ucp/value_objects.rb', line 275

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



282
283
284
285
286
287
288
289
# File 'lib/portage/ucp/value_objects.rb', line 282

def to_wire_h
  h = { "id" => id, "title" => title, "totals" => totals.map(&:to_wire_h) }
  h["description"] = description if description
  h["carrier"] = carrier if carrier
  h["earliest_fulfillment_time"] = earliest_fulfillment_time if earliest_fulfillment_time
  h["latest_fulfillment_time"] = latest_fulfillment_time if latest_fulfillment_time
  h
end