Class: Portage::Ucp::OrderLineItem

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

Overview

schemas/shopping/types/order_line_item.json — distinct from LineItem: quantity is original,total,fulfilled tracking, plus a derived status enum, not a bare integer.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, item:, quantity:, totals:, status:, parent_id: nil) ⇒ OrderLineItem

Returns a new instance of OrderLineItem.



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

def initialize(id:, item:, quantity:, totals:, status:, parent_id: nil) = super

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item

Returns:

  • (Object)

    the current value of item



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def item
  @item
end

#parent_idObject (readonly)

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def parent_id
  @parent_id
end

#quantityObject (readonly)

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def quantity
  @quantity
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def status
  @status
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



95
96
97
# File 'lib/portage/ucp/value_objects.rb', line 95

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



98
99
100
101
102
103
104
105
# File 'lib/portage/ucp/value_objects.rb', line 98

def to_wire_h
  q = { "total" => quantity[:total], "fulfilled" => quantity[:fulfilled] }
  q["original"] = quantity[:original] if quantity[:original]
  h = { "id" => id, "item" => item.to_wire_h, "quantity" => q, "totals" => totals.map(&:to_wire_h),
        "status" => status }
  h["parent_id"] = parent_id if parent_id
  h
end