Class: Portage::Ucp::Adjustment

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

Overview

schemas/shopping/types/adjustment.json — post-order event independent of fulfillment (refund, return, credit, price_adjustment, dispute, cancellation, ...). status is pending/completed/failed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, type:, occurred_at:, status:, line_items: nil, totals: nil, description: nil) ⇒ Adjustment

Returns a new instance of Adjustment.



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

def initialize(id:, type:, occurred_at:, status:, line_items: nil, totals: nil, description: nil) = super

Instance Attribute Details

#descriptionObject (readonly)

Returns the value of attribute description

Returns:

  • (Object)

    the current value of description



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def id
  @id
end

#line_itemsObject (readonly)

Returns the value of attribute line_items

Returns:

  • (Object)

    the current value of line_items



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def line_items
  @line_items
end

#occurred_atObject (readonly)

Returns the value of attribute occurred_at

Returns:

  • (Object)

    the current value of occurred_at



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def occurred_at
  @occurred_at
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def status
  @status
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def totals
  @totals
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



153
154
155
# File 'lib/portage/ucp/value_objects.rb', line 153

def type
  @type
end

Instance Method Details

#to_wire_hObject



156
157
158
159
160
161
162
# File 'lib/portage/ucp/value_objects.rb', line 156

def to_wire_h
  h = { "id" => id, "type" => type, "occurred_at" => occurred_at, "status" => status }
  h["line_items"] = line_items if line_items
  h["totals"] = totals.map(&:to_wire_h) if totals
  h["description"] = description if description
  h
end