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.



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

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



182
183
184
# File 'lib/portage/ucp/value_objects.rb', line 182

def id
  @id
end

#image_urlObject (readonly)

Returns the value of attribute image_url

Returns:

  • (Object)

    the current value of image_url



182
183
184
# File 'lib/portage/ucp/value_objects.rb', line 182

def image_url
  @image_url
end

#priceObject (readonly)

Returns the value of attribute price

Returns:

  • (Object)

    the current value of price



182
183
184
# File 'lib/portage/ucp/value_objects.rb', line 182

def price
  @price
end

#titleObject (readonly)

Returns the value of attribute title

Returns:

  • (Object)

    the current value of title



182
183
184
# File 'lib/portage/ucp/value_objects.rb', line 182

def title
  @title
end

Instance Method Details

#to_wire_hObject



185
186
187
188
189
# File 'lib/portage/ucp/value_objects.rb', line 185

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