Class: TaxCloud::Responses::Lookup
- Defined in:
- lib/tax_cloud/responses/lookup.rb
Overview
Response to a TaxCloud Lookup API call.
Instance Attribute Summary collapse
-
#cart_id ⇒ Object
Cart ID.
-
#cart_items ⇒ Object
Cart items.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(savon_response) ⇒ Lookup
constructor
Parameters [savon_response] SOAP response.
-
#tax_amount ⇒ Object
Total tax amount in this cart.
Methods inherited from Base
error_message, error_number, #match, parse, response_type, set_dsl
Constructor Details
#initialize(savon_response) ⇒ Lookup
Parameters
- savon_response
-
SOAP response.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# 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') if cart_item_responses.is_a?(Array) self.cart_items = cart_item_responses.map do |cart_item_response| TaxCloud::Responses::CartItem.new(cart_item_response) end else self.cart_items = [TaxCloud::Responses::CartItem.new(cart_item_responses)] end end |
Instance Attribute Details
#cart_id ⇒ Object
Cart ID.
8 9 10 |
# File 'lib/tax_cloud/responses/lookup.rb', line 8 def cart_id @cart_id end |
#cart_items ⇒ Object
Cart items.
11 12 13 |
# File 'lib/tax_cloud/responses/lookup.rb', line 11 def cart_items @cart_items end |
Instance Method Details
#tax_amount ⇒ Object
Total tax amount in this cart.
33 34 35 |
# File 'lib/tax_cloud/responses/lookup.rb', line 33 def tax_amount cart_items.reduce(0) { |a, e| a + e.tax_amount } end |