Class: Portage::Ucp::OrderLineItem
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::OrderLineItem
- 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
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#item ⇒ Object
readonly
Returns the value of attribute item.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Instance Method Summary collapse
-
#initialize(id:, item:, quantity:, totals:, status:, parent_id: nil) ⇒ OrderLineItem
constructor
A new instance of OrderLineItem.
- #to_wire_h ⇒ Object
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
#id ⇒ Object (readonly)
Returns the value of attribute id
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def id @id end |
#item ⇒ Object (readonly)
Returns the value of attribute item
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def item @item end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def parent_id @parent_id end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def quantity @quantity end |
#status ⇒ Object (readonly)
Returns the value of attribute status
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def status @status end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals
95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 95 def totals @totals end |
Instance Method Details
#to_wire_h ⇒ Object
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 |