class VertexClient::Response::Quotation

Public Instance Methods

line_items() click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 17
def line_items
  @line_items ||= normalized_line_items.map do |line_item|
    LineItem.new(
      product:        product_for_line_item(line_item[:product]),
      quantity:       line_item[:quantity],
      price:          line_item[:extended_price],
      total_tax:      tax_for_line_item(line_item)
    )
  end
end
subtotal() click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 5
def subtotal
  @subtotal ||= BigDecimal.new(@body[:sub_total])
end
total() click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 13
def total
  @total ||= BigDecimal.new(@body[:total])
end
total_tax() click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 9
def total_tax
  @total_tax ||= BigDecimal.new(@body[:total_tax])
end

Private Instance Methods

normalized_line_items() click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 48
def normalized_line_items
  [ @body[:line_item] ].flatten
end
product_for_line_item(product) click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 30
def product_for_line_item(product)
  if(product).is_a?(Nori::StringWithAttributes)
    LineItemProduct.new(
      product_code:   product.to_s,
      product_class:  product.attributes['productClass'],
    )
  else
    LineItemProduct.new(
      product_code:   product['@product_code'],
      product_class:  product['@product_class'],
    )
  end
end
tax_for_line_item(line_item) click to toggle source
# File lib/vertex_client/responses/quotation.rb, line 44
def tax_for_line_item(line_item)
  line_item[:total_tax]
end