Class: Portage::Ucp::Discounts
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::Discounts
- Defined in:
- lib/portage/ucp/value_objects.rb
Overview
schemas/shopping/discount.json#/$defs/discounts_object — codes is the
request-side input (case-insensitive, full-replacement — send [] to
clear); applied is the response-side result. Both optional, so a Cart/
Checkout with no discount activity omits the whole field (see Cart/
Checkout#to_wire_h below), same posture as Order#adjustments.
Instance Attribute Summary collapse
-
#applied ⇒ Object
readonly
Returns the value of attribute applied.
-
#codes ⇒ Object
readonly
Returns the value of attribute codes.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(codes: [], applied: []) ⇒ Discounts
constructor
A new instance of Discounts.
- #to_wire_h ⇒ Object
Constructor Details
#initialize(codes: [], applied: []) ⇒ Discounts
Returns a new instance of Discounts.
363 |
# File 'lib/portage/ucp/value_objects.rb', line 363 def initialize(codes: [], applied: []) = super |
Instance Attribute Details
#applied ⇒ Object (readonly)
Returns the value of attribute applied
362 363 364 |
# File 'lib/portage/ucp/value_objects.rb', line 362 def applied @applied end |
#codes ⇒ Object (readonly)
Returns the value of attribute codes
362 363 364 |
# File 'lib/portage/ucp/value_objects.rb', line 362 def codes @codes end |
Instance Method Details
#empty? ⇒ Boolean
365 |
# File 'lib/portage/ucp/value_objects.rb', line 365 def empty? = codes.empty? && applied.empty? |
#to_wire_h ⇒ Object
367 368 369 370 371 372 |
# File 'lib/portage/ucp/value_objects.rb', line 367 def to_wire_h h = {} h["codes"] = codes unless codes.empty? h["applied"] = applied.map(&:to_wire_h) unless applied.empty? h end |