Class: Portage::Ucp::Cart
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::Cart
- Defined in:
- lib/portage/ucp/value_objects.rb
Overview
schemas/shopping/cart.json — requires ucp/id/line_items/currency/totals.
The "ucp" envelope is added centrally by Portage::Ucp::WireEnvelope, not stored
on the value object itself.
discounts is the dev.ucp.shopping.discount extension (optional on both
cart.json and its own schema) — omitted from the wire payload when empty,
same as Order#adjustments.
Instance Attribute Summary collapse
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#discounts ⇒ Object
readonly
Returns the value of attribute discounts.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Instance Method Summary collapse
-
#initialize(id:, line_items:, currency:, totals:, discounts: Discounts.new) ⇒ Cart
constructor
A new instance of Cart.
- #to_wire_h ⇒ Object
Constructor Details
Instance Attribute Details
#currency ⇒ Object (readonly)
Returns the value of attribute currency
381 382 383 |
# File 'lib/portage/ucp/value_objects.rb', line 381 def currency @currency end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts
381 382 383 |
# File 'lib/portage/ucp/value_objects.rb', line 381 def discounts @discounts end |
#id ⇒ Object (readonly)
Returns the value of attribute id
381 382 383 |
# File 'lib/portage/ucp/value_objects.rb', line 381 def id @id end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items
381 382 383 |
# File 'lib/portage/ucp/value_objects.rb', line 381 def line_items @line_items end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals
381 382 383 |
# File 'lib/portage/ucp/value_objects.rb', line 381 def totals @totals end |
Instance Method Details
#to_wire_h ⇒ Object
384 385 386 387 388 389 |
# File 'lib/portage/ucp/value_objects.rb', line 384 def to_wire_h h = { "id" => id, "line_items" => line_items.map(&:to_wire_h), "currency" => currency, "totals" => totals.map(&:to_wire_h) } h["discounts"] = discounts.to_wire_h unless discounts.empty? h end |