adamfortuna / avalara

A Ruby interface to the Avalara Tax API.
MIT License
26 stars 47 forks source link

Invoice object not getting filled #7

Closed vemv closed 9 years ago

vemv commented 10 years ago

For some reason an apparently successful request (it looks successful - see below) results in the corresonding Avalara::Response::Invoice object with all its fields set to nil instead.

[83, 92] in /home/vagrant/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/avalara-0.0.3/lib/avalara.rb
   83        :body => invoice.to_json,
   84        :headers => API.headers_for(invoice.to_json.length),
   85        :basic_auth => authentication
   86      )
   87   debugger
=> 88      return case response.code
   89        when 200..299
   90          Response::Invoice.new(response)
   91        when 400..599
   92          raise ApiError.new(Response::Invoice.new(response))
(rdb:1) response
#<HTTParty::Response:0x7fa8bb7729d0 parsed_response={"ResultCode"=>
"Success", "DocCode"=>"7d9a6855-b504-4b27-93c9-07f08db5359f",
"DocDate"=>"2014-06-09", "Timestamp"=>"2014-06-09T16:51:37.5020571Z", 
"TotalAmount"=>"2", "TotalDiscount"=>"0", "TotalExemption"=>"0",
"TotalTaxable"=>"2", "TotalTax"=>"0.14", "TotalTaxCalculated"=>"0.14",
"TaxLines"=>[{"LineNo"=>"0", "TaxCode"=>"P0000000", 
"Taxability"=>"true", "BoundaryLevel"=>"Address", "Exemption"=>"0", "Discount"=>"0",
"Taxable"=>"2", "Rate"=>"0.070000", "Tax"=>"0.14", "TaxCalculated"=>"0.14", 
"TaxDetails"=>[{"Country"=>"US", "Region"=>"NJ", "JurisType"=>"State", "Taxable"=>"2", 
"Rate"=>"0.070000", "Tax"=>"0.14", "JurisName"=>"NEW JERSEY",
"TaxName"=>"NJ STATE TAX"}]}], "TaxAddresses"=>[{"Address"=>"1111 Bayhill Dr Ste 375", 
"AddressCode"=>"1", "Country"=>"US", "PostalCode"=>"94037", "Region"=>"CA", 
"TaxRegionId"=>"0", "JurisCode"=>"0600000000"}, {"Address"=>"117 Sherbrook Dr Apt 
3B", "AddressCode"=>"2", "City"=>"Berkeley Heights", "Country"=>"US", 
"PostalCode"=>"07922-2347", "Region"=>"NJ", "TaxRegionId"=>"2118369", 
"JurisCode"=>"3400000000"}], "TaxDate"=>"2014-06-09"}, @response=#<Net::HTTPOK 
200 OK readbody=true>, @headers={"cache-control"=>["private"], "content-type"=>
["text/json; charset=utf-8"], "x-aspnet-version"=>["4.0.30319"], "x-powered-by"=>
["ASP.NET"], "date"=>["Mon, 09 Jun 2014 16:51:36 GMT"], "connection"=>["close"], 
"content-length"=>["1098"]}>
(rdb:1) Response::Invoice.new(response)
#<Avalara::Response::Invoice>
HoyaBoya commented 10 years ago

I am encountering the same thing. I noticed that my issue was that I was using the latest Hashie version of 3.2.0, which required that we add

      include Hashie::Extensions::IndifferentAccess

To the Avalara::Types::Stash object.

adamfortuna commented 9 years ago

Good catch! I'm thinking this should be fixed by the hashie update that went out today. If you run into any other issues with it, definitely let me know.