class TaxCloud::Responses::Lookup

Response to a TaxCloud Lookup API call.

See api.taxcloud.net/1.0/TaxCloud.asmx?op=Lookup.

Attributes

cart_id[RW]

Cart ID.

cart_items[RW]

Cart items.

Public Class Methods

new(savon_response) click to toggle source

Parameters

savon_response

SOAP response.

Calls superclass method TaxCloud::Responses::Base::new
# File lib/tax_cloud/responses/lookup.rb, line 18
def initialize(savon_response)
  super savon_response
  self.cart_id = match('lookup_response/lookup_result/cart_id')
  # there can be on response or an array of responses
  cart_item_responses = match('lookup_response/lookup_result/cart_items_response/cart_item_response')
  self.cart_items = if cart_item_responses.is_a?(Array)
                      cart_item_responses.map do |cart_item_response|
                        TaxCloud::Responses::CartItem.new(cart_item_response)
                      end
                    else
                      [TaxCloud::Responses::CartItem.new(cart_item_responses)]
                    end
end

Public Instance Methods

tax_amount() click to toggle source

Total tax amount in this cart.

# File lib/tax_cloud/responses/lookup.rb, line 33
def tax_amount
  cart_items.reduce(0) { |a, e| a + e.tax_amount }
end