Class: Portage::Ucp::Checkout

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

Overview

schemas/shopping/checkout.json — requires ucp/id/line_items/status/ currency/totals/links. status is the real enum (incomplete, requires_escalation, ready_for_complete, complete_in_progress, completed, canceled) — not the old ad hoc "pending"/"completed" strings. order is the schema's optional order_confirmation — set once complete_checkout actually produces an order, nil otherwise.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, status:, line_items:, currency:, totals:, links:, order: nil) ⇒ Checkout

Returns a new instance of Checkout.



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

def initialize(id:, status:, line_items:, currency:, totals:, links:, order: nil) = super

Instance Attribute Details

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def currency
  @currency
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def id
  @id
end

#line_itemsObject (readonly)

Returns the value of attribute line_items

Returns:

  • (Object)

    the current value of line_items



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def line_items
  @line_items
end

Returns the value of attribute links

Returns:

  • (Object)

    the current value of links



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def links
  @links
end

#orderObject (readonly)

Returns the value of attribute order

Returns:

  • (Object)

    the current value of order



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def order
  @order
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def status
  @status
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



81
82
83
# File 'lib/portage/ucp/value_objects.rb', line 81

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



84
85
86
87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 84

def to_wire_h
  h = { "id" => id, "status" => status, "line_items" => line_items.map(&:to_wire_h),
        "currency" => currency, "totals" => totals.map(&:to_wire_h), "links" => links.map(&:to_wire_h) }
  h["order"] = order.to_wire_h if order
  h
end