Class: Portage::Ucp::Order

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

Overview

schemas/shopping/order.json — requires ucp/id/checkout_id/permalink_url/ line_items/fulfillment/currency/totals. adjustments is optional — omitted from the wire payload when empty.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, checkout_id:, permalink_url:, line_items:, fulfillment:, currency:, totals:, adjustments: []) ⇒ Order

Returns a new instance of Order.



170
171
172
173
# File 'lib/portage/ucp/value_objects.rb', line 170

def initialize(id:, checkout_id:, permalink_url:, line_items:, fulfillment:, currency:, totals:,
               adjustments: [])
  super
end

Instance Attribute Details

#adjustmentsObject (readonly)

Returns the value of attribute adjustments

Returns:

  • (Object)

    the current value of adjustments



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def adjustments
  @adjustments
end

#checkout_idObject (readonly)

Returns the value of attribute checkout_id

Returns:

  • (Object)

    the current value of checkout_id



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def checkout_id
  @checkout_id
end

#currencyObject (readonly)

Returns the value of attribute currency

Returns:

  • (Object)

    the current value of currency



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def currency
  @currency
end

#fulfillmentObject (readonly)

Returns the value of attribute fulfillment

Returns:

  • (Object)

    the current value of fulfillment



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def fulfillment
  @fulfillment
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def id
  @id
end

#line_itemsObject (readonly)

Returns the value of attribute line_items

Returns:

  • (Object)

    the current value of line_items



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def line_items
  @line_items
end

Returns the value of attribute permalink_url

Returns:

  • (Object)

    the current value of permalink_url



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def permalink_url
  @permalink_url
end

#totalsObject (readonly)

Returns the value of attribute totals

Returns:

  • (Object)

    the current value of totals



168
169
170
# File 'lib/portage/ucp/value_objects.rb', line 168

def totals
  @totals
end

Instance Method Details

#to_wire_hObject



175
176
177
178
179
180
181
# File 'lib/portage/ucp/value_objects.rb', line 175

def to_wire_h
  h = { "id" => id, "checkout_id" => checkout_id, "permalink_url" => permalink_url,
        "line_items" => line_items.map(&:to_wire_h), "fulfillment" => fulfillment.to_wire_h,
        "currency" => currency, "totals" => totals.map(&:to_wire_h) }
  h["adjustments"] = adjustments.map(&:to_wire_h) unless adjustments.empty?
  h
end