Skip to content

Commit

Permalink
Remove additional code. Always make sure that jurisdictions is an Array.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewtempelmeyer committed Sep 18, 2012
1 parent 0ad3c09 commit a6a2fa8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
8 changes: 2 additions & 6 deletions .travis.yml
@@ -1,12 +1,8 @@
language: ruby
before_install:
- gem update --system
- gem install bundler --pre
rvm:
- 1.9.2
- 1.9.3
- 1.8.7
- jruby-19mode
- jruby-head
- rbx-18mode
- rbx-19mode
- jruby-18mode
script: rake test
21 changes: 8 additions & 13 deletions lib/strikeiron/tax_result.rb
Expand Up @@ -17,25 +17,20 @@ def initialize(default_values = {})
class << self
# Convert the object from the Strikeiron response
def from_soap(response)
tax_values = []
tax_values = []
response_records = response[:results][:tax_value_record]
response_records = [ response_records ] if response_records.is_a?(Hash)

response_records.each do |record|
jurisdictions = record[:jurisdictions][:sales_tax_value_jurisdiction]
jurisdictions = [ jurisdictions ] if jurisdictions.is_a?(Hash)

if response[:results][:tax_value_record].is_a?(Hash)
record = response[:results][:tax_value_record]
tax_values << TaxValue.new(
:category => record[:category],
:category_id => record[:category_id],
:tax_amount => record[:sales_tax_amount].to_f,
:jurisdictions => record[:jurisdictions][:sales_tax_value_jurisdiction].map { |j| Jurisdiction.new(:fips => j[:fips], :name => j[:name], :tax_amount => j[:sales_tax_amount].to_f) }
:jurisdictions => jurisdictions.map { |j| Jurisdiction.new(:fips => j[:fips], :name => j[:name], :tax_amount => j[:sales_tax_amount].to_f) }
)
else
response[:results][:tax_value_record].each do |record|
tax_values << TaxValue.new(
:category => record[:category],
:category_id => record[:category_id],
:tax_amount => record[:sales_tax_amount].to_f,
:jurisdictions => record[:jurisdictions][:sales_tax_value_jurisdiction].map { |j| Jurisdiction.new(:fips => j[:fips], :name => j[:name], :tax_amount => j[:sales_tax_amount].to_f) }
)
end
end

new(
Expand Down
2 changes: 1 addition & 1 deletion lib/strikeiron/version.rb
@@ -1,3 +1,3 @@
module Strikeiron
VERSION = "0.0.2"
VERSION = "0.0.3"
end

0 comments on commit a6a2fa8

Please sign in to comment.