Class: Portage::Ucp::Variant

Inherits:
Data
  • Object
show all
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

Instance Method Summary collapse

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

#availabilityObject (readonly)

Returns the value of attribute availability

Returns:

  • (Object)

    the current value of availability



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def availability
  @availability
end

#barcodesObject (readonly)

Returns the value of attribute barcodes

Returns:

  • (Object)

    the current value of barcodes



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def barcodes
  @barcodes
end

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def id
  @id
end

#list_priceObject (readonly)

Returns the value of attribute list_price

Returns:

  • (Object)

    the current value of list_price



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def list_price
  @list_price
end

#mediaObject (readonly)

Returns the value of attribute media

Returns:

  • (Object)

    the current value of media



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def media
  @media
end

#metadataObject (readonly)

Returns the value of attribute metadata

Returns:

  • (Object)

    the current value of metadata



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def 
  @metadata
end

#optionsObject (readonly)

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def options
  @options
end

#priceObject (readonly)

Returns the value of attribute price

Returns:

  • (Object)

    the current value of price



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def price
  @price
end

#skuObject (readonly)

Returns the value of attribute sku

Returns:

  • (Object)

    the current value of sku



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def sku
  @sku
end

#tagsObject (readonly)

Returns the value of attribute tags

Returns:

  • (Object)

    the current value of tags



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def tags
  @tags
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



87
88
89
# File 'lib/portage/ucp/value_objects.rb', line 87

def title
  @title
end

Instance Method Details

#to_wire_hObject



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