Class: Portage::Ucp::Variant
- Inherits:
-
Data
- Object
- Data
- Portage::Ucp::Variant
- Defined in:
- lib/portage/ucp/value_objects.rb
Overview
schemas/shopping/types/variant.json — a purchasable variant of a
Product. id is what LineItem#item.id actually references at
checkout, not Product#id.
barcodes and availability are left as plain wire-shaped hashes
({"type" =>, "value" =>} / {"available" =>, "status" =>}) rather
than their own Data types — both are simple, spec doesn't name them as
standalone $refs, and the parent's to_wire_h needs them exactly as
given, same posture as Adjustment#line_items' inline hashes.
Instance Attribute Summary collapse
-
#availability ⇒ Object
readonly
Returns the value of attribute availability.
-
#barcodes ⇒ Object
readonly
Returns the value of attribute barcodes.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#list_price ⇒ Object
readonly
Returns the value of attribute list_price.
-
#media ⇒ Object
readonly
Returns the value of attribute media.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#sku ⇒ Object
readonly
Returns the value of attribute sku.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#initialize(id:, title:, description:, price:, sku: nil, barcodes: [], list_price: nil, availability: nil, options: [], media: [], tags: [], metadata: nil) ⇒ Variant
constructor
A new instance of Variant.
- #to_wire_h ⇒ Object
Constructor Details
#initialize(id:, title:, description:, price:, sku: nil, barcodes: [], list_price: nil, availability: nil, options: [], media: [], tags: [], metadata: nil) ⇒ Variant
Returns a new instance of Variant.
89 90 91 92 |
# File 'lib/portage/ucp/value_objects.rb', line 89 def initialize(id:, title:, description:, price:, sku: nil, barcodes: [], list_price: nil, availability: nil, options: [], media: [], tags: [], metadata: nil) super end |
Instance Attribute Details
#availability ⇒ Object (readonly)
Returns the value of attribute availability
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def availability @availability end |
#barcodes ⇒ Object (readonly)
Returns the value of attribute barcodes
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def @barcodes end |
#description ⇒ Object (readonly)
Returns the value of attribute description
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def id @id end |
#list_price ⇒ Object (readonly)
Returns the value of attribute list_price
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def list_price @list_price end |
#media ⇒ Object (readonly)
Returns the value of attribute media
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def media @media end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def @metadata end |
#options ⇒ Object (readonly)
Returns the value of attribute options
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def @options end |
#price ⇒ Object (readonly)
Returns the value of attribute price
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def price @price end |
#sku ⇒ Object (readonly)
Returns the value of attribute sku
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def sku @sku end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title
87 88 89 |
# File 'lib/portage/ucp/value_objects.rb', line 87 def title @title end |
Instance Method Details
#to_wire_h ⇒ Object
94 95 96 97 |
# File 'lib/portage/ucp/value_objects.rb', line 94 def to_wire_h { "id" => id, "title" => title, "description" => description.to_wire_h, "price" => price.to_wire_h }.merge(optional_wire_h) end |