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.



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

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



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def id
  @id
end

#itemObject (readonly)

Returns the value of attribute item

Returns:

  • (Object)

    the current value of item



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def item
  @item
end

#parent_idObject (readonly)

Returns the value of attribute parent_id

Returns:

  • (Object)

    the current value of parent_id



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def parent_id
  @parent_id
end

#quantityObject (readonly)

Returns the value of attribute quantity

Returns:

  • (Object)

    the current value of quantity



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def quantity
  @quantity
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def status
  @status
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



435
436
437
# File 'lib/portage/ucp/value_objects.rb', line 435

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



438
439
440
441
442
443
444
445
# File 'lib/portage/ucp/value_objects.rb', line 438

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