Class: Portage::Ucp::Checkout
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::Checkout
- 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.
discounts — same dev.ucp.shopping.discount extension as Cart, above.
fulfillment — the dev.ucp.shopping.fulfillment extension (optional,
omitted from the wire payload when empty), same posture 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.
-
#fulfillment ⇒ Object
readonly
Returns the value of attribute fulfillment.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#line_items ⇒ Object
readonly
Returns the value of attribute line_items.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#totals ⇒ Object
readonly
Returns the value of attribute totals.
Instance Method Summary collapse
-
#initialize(id:, status:, line_items:, currency:, totals:, links:, order: nil, discounts: Discounts.new, fulfillment: CheckoutFulfillment.new) ⇒ Checkout
constructor
A new instance of Checkout.
- #to_wire_h ⇒ Object
Constructor Details
#initialize(id:, status:, line_items:, currency:, totals:, links:, order: nil, discounts: Discounts.new, fulfillment: CheckoutFulfillment.new) ⇒ Checkout
Returns a new instance of Checkout.
417 418 419 420 |
# File 'lib/portage/ucp/value_objects.rb', line 417 def initialize(id:, status:, line_items:, currency:, totals:, links:, order: nil, discounts: Discounts.new, fulfillment: CheckoutFulfillment.new) super end |
Instance Attribute Details
#currency ⇒ Object (readonly)
Returns the value of attribute currency
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def currency @currency end |
#discounts ⇒ Object (readonly)
Returns the value of attribute discounts
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def discounts @discounts end |
#fulfillment ⇒ Object (readonly)
Returns the value of attribute fulfillment
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def fulfillment @fulfillment end |
#id ⇒ Object (readonly)
Returns the value of attribute id
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def id @id end |
#line_items ⇒ Object (readonly)
Returns the value of attribute line_items
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def line_items @line_items end |
#links ⇒ Object (readonly)
Returns the value of attribute links
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def links @links end |
#order ⇒ Object (readonly)
Returns the value of attribute order
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def order @order end |
#status ⇒ Object (readonly)
Returns the value of attribute status
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def status @status end |
#totals ⇒ Object (readonly)
Returns the value of attribute totals
415 416 417 |
# File 'lib/portage/ucp/value_objects.rb', line 415 def totals @totals end |
Instance Method Details
#to_wire_h ⇒ Object
422 423 424 425 426 427 428 429 |
# File 'lib/portage/ucp/value_objects.rb', line 422 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["discounts"] = discounts.to_wire_h unless discounts.empty? h["fulfillment"] = fulfillment.to_wire_h unless fulfillment.empty? h end |