Class: Portage::Ucp::Item

Inherits:
Data
  • Object
show all
Defined in:
lib/portage/ucp/value_objects.rb

Overview

Product identity on a line item (schemas/shopping/types/item.json). price is a bare integer minor-unit amount — the parent object's currency applies.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, title:, price:, image_url: nil) ⇒ Item

Returns a new instance of Item.



23
# File 'lib/portage/ucp/value_objects.rb', line 23

def initialize(id:, title:, price:, image_url: nil) = super

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



22
23
24
# File 'lib/portage/ucp/value_objects.rb', line 22

def id
  @id
end

#image_urlObject (readonly)

Returns the value of attribute image_url

Returns:

  • (Object)

    the current value of image_url



22
23
24
# File 'lib/portage/ucp/value_objects.rb', line 22

def image_url
  @image_url
end

#priceObject (readonly)

Returns the value of attribute price

Returns:

  • (Object)

    the current value of price



22
23
24
# File 'lib/portage/ucp/value_objects.rb', line 22

def price
  @price
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



22
23
24
# File 'lib/portage/ucp/value_objects.rb', line 22

def title
  @title
end

Instance Method Details

#to_wire_hObject



25
26
27
28
29
# File 'lib/portage/ucp/value_objects.rb', line 25

def to_wire_h
  h = { "id" => id, "title" => title, "price" => price }
  h["image_url"] = image_url if image_url
  h
end