Class: Portage::Ucp::Order

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

Overview

schemas/shopping/order.json — requires ucp/id/checkout_id/permalink_url/ line_items/fulfillment/currency/totals. adjustments is optional — omitted from the wire payload when empty.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, checkout_id:, permalink_url:, line_items:, fulfillment:, currency:, totals:, adjustments: []) ⇒ Order

Returns a new instance of Order.



510
511
512
513
# File 'lib/portage/ucp/value_objects.rb', line 510

def initialize(id:, checkout_id:, permalink_url:, line_items:, fulfillment:, currency:, totals:,
               adjustments: [])
  super
end

Instance Attribute Details

#adjustmentsObject (readonly)

Returns the value of attribute adjustments

Returns:

  • (Object)

    the current value of adjustments



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def adjustments
  @adjustments
end

#checkout_idObject (readonly)

Returns the value of attribute checkout_id

Returns:

  • (Object)

    the current value of checkout_id



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def checkout_id
  @checkout_id
end

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def currency
  @currency
end

#fulfillmentObject (readonly)

Returns the value of attribute fulfillment

Returns:

  • (Object)

    the current value of fulfillment



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def fulfillment
  @fulfillment
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def id
  @id
end

#line_itemsObject (readonly)

Returns the value of attribute line_items

Returns:

  • (Object)

    the current value of line_items



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def line_items
  @line_items
end

Returns the value of attribute permalink_url

Returns:

  • (Object)

    the current value of permalink_url



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def permalink_url
  @permalink_url
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



508
509
510
# File 'lib/portage/ucp/value_objects.rb', line 508

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



515
516
517
518
519
520
521
# File 'lib/portage/ucp/value_objects.rb', line 515

def to_wire_h
  h = { "id" => id, "checkout_id" => checkout_id, "permalink_url" => permalink_url,
        "line_items" => line_items.map(&:to_wire_h), "fulfillment" => fulfillment.to_wire_h,
        "currency" => currency, "totals" => totals.map(&:to_wire_h) }
  h["adjustments"] = adjustments.map(&:to_wire_h) unless adjustments.empty?
  h
end