Avatax_TaxService 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- N2JhMDM0YTBiNmUwN2NhZGYzOTg4ZWFmOGNlYTJmODgyYWMwY2ExNw==
4
+ ZGJiODRjYzA0ZmIwOTYwMDE3NDYyNzE3NGY3OTViMzA5Nzg2MzEzOQ==
5
5
  data.tar.gz: !binary |-
6
- MWE5MmQ5MDc4ODRjNzk4NzUyMzQyNzhhYzViOGJjZTZmNzdjMzc2OA==
6
+ MTZkM2MzODkzYmY2OTc3YjNiZWM3OGQzMzJmMTAyNjE3Y2YwYjQ4Nw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OGVhODZlZjQ3OTFkMWY2NzE5ZmI3OGQwMGJiYWE3M2NiMGYxOTllZjJhYjVj
10
- NzdiYzU1NDUyZjkxNWRjZjMyYzFmYmVlNmM0NmFlZTgwMjE3YTdhMjMyNmI5
11
- MjU3ZDBmN2U3NjJkOGQyOWYzZmFiYmIzNTIyMTdkNzA4OWUyZGU=
9
+ NDMzNDc4YTE5OGZjNmNmYTY2NTI5NTk4ZTFhYWYzZTNiMGM2ODkwN2E1OTM1
10
+ ZDQxZDJlZTY4MDVhYTM4Y2U5OTM1NjBkYzU0NzMyZDMzOGU5NmRhNWZlZjQy
11
+ ZGVlMzkyZjM2ODNmMmE2ZTBmMmUwOGM1NGIzYjcyZTlkMDI5YzY=
12
12
  data.tar.gz: !binary |-
13
- OTBkZWVlNzU3ZmUwZDBjNjA4NDU5ZTQ0NmYyZWNmZmE5ZWY0NDAzYTE5YjA4
14
- NmZkZDdiNDIxOWVlMjQwYTI0Mzg4OWE2OGRlOTdlNDc0YmJhNjA4ZTM5MThm
15
- YzgyYTRhMGM2NjExZTExOTJhODRhYjJiZDhmYWQ5ZTAyNjIwNWU=
13
+ NWJmMDcyZmRkN2FjNWIzMjI3MjVhNGJlYWE1NGU2NWQ2NmNjMTQ1OTdmMTUy
14
+ NDBmYzRjNjk5Y2VkYjVhZjVkY2E5MTkyMWIxNjk3ODM5NWRiZTU0OWIxOTMw
15
+ YTNhMzE5YTVhOTk0M2I1YWY5M2U2NzAwMjc5MTlhYWYwNGUzMTU=
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Avatax_TaxService"
3
- s.version = "1.0.12"
3
+ s.version = "1.0.13"
4
4
  s.date = "2012-10-28"
5
5
  s.author = "Graham S Wilson"
6
6
  s.email = "support@Avalara.com"
@@ -156,7 +156,7 @@ module AvaTax
156
156
  end
157
157
 
158
158
  #Strip off outer layer of the hash - not needed
159
- @response = @response[:ping_response][:ping_result]
159
+ @response = messages_to_array(@response[:ping_response][:ping_result])
160
160
 
161
161
  return @response
162
162
 
@@ -236,7 +236,7 @@ module AvaTax
236
236
  end
237
237
 
238
238
  #Strip off outer layer of the hash - not needed
239
- @response = @response[:get_tax_response][:get_tax_result]
239
+ @response = messages_to_array(@response[:get_tax_response][:get_tax_result])
240
240
 
241
241
  #Return data to calling program
242
242
  return @response
@@ -317,7 +317,7 @@ module AvaTax
317
317
  end
318
318
 
319
319
  #Strip off outer layer of the hash - not needed
320
- return @response[:adjust_tax_response][:adjust_tax_result]
320
+ return messages_to_array(@response[:adjust_tax_response][:adjust_tax_result])
321
321
 
322
322
  #Capture unexpected errors
323
323
  rescue Savon::Error => error
@@ -369,7 +369,7 @@ module AvaTax
369
369
 
370
370
  #Strip off outer layer of the hash - not needed
371
371
  #Return data to calling program
372
- return @response[:post_tax_response][:post_tax_result]
372
+ return messages_to_array(@response[:post_tax_response][:post_tax_result])
373
373
 
374
374
  #Capture unexpected errors
375
375
  rescue Savon::Error => error
@@ -419,7 +419,7 @@ module AvaTax
419
419
 
420
420
  #Strip off outer layer of the hash - not needed
421
421
  #Return data to calling program
422
- return @response[:commit_tax_response][:commit_tax_result]
422
+ return messages_to_array(@response[:commit_tax_response][:commit_tax_result])
423
423
 
424
424
  #Capture unexpected errors
425
425
  rescue Savon::Error => error
@@ -467,7 +467,7 @@ module AvaTax
467
467
  end
468
468
 
469
469
  #Strip off outer layer of the hash - not needed
470
- return @response[:cancel_tax_response][:cancel_tax_result]
470
+ return messages_to_array(@response[:cancel_tax_response][:cancel_tax_result])
471
471
 
472
472
  #Capture unexpected errors
473
473
  rescue Savon::Error => error
@@ -515,7 +515,7 @@ module AvaTax
515
515
  end
516
516
 
517
517
  #Strip off outer layer of the hash - not needed
518
- return @response[:get_tax_history_response][:get_tax_history_result]
518
+ return messages_to_array(@response[:get_tax_history_response][:get_tax_history_result])
519
519
 
520
520
 
521
521
  #Capture unexpected errors
@@ -571,7 +571,7 @@ module AvaTax
571
571
  end
572
572
 
573
573
  #Strip off outer layer of the hash - not needed
574
- return @response[:reconcile_tax_history_response][:reconcile_tax_history_result]
574
+ return messages_to_array(@response[:reconcile_tax_history_response][:reconcile_tax_history_result])
575
575
 
576
576
  #Capture unexpected errors
577
577
  rescue Savon::Error => error
@@ -601,7 +601,7 @@ module AvaTax
601
601
  @response = @client.call(:is_authorized, xml: @soap).to_hash
602
602
 
603
603
  #Strip off outer layer of the hash - not needed
604
- return @response[:is_authorized_response][:is_authorized_result]
604
+ return messages_to_array(@response[:is_authorized_response][:is_authorized_result])
605
605
 
606
606
  #Capture unexpected errors
607
607
  rescue Savon::Error => error
@@ -621,8 +621,29 @@ module AvaTax
621
621
  @response[:result_code] = 'Error'
622
622
  @response[:summary] = @response[:fault][:faultcode]
623
623
  @response[:details] = @response[:fault][:faultstring]
624
- return @response
624
+ return messages_to_array(@response)
625
+ end
626
+ ############################################################################################################
627
+ #standardizes error message format to an array of messages - nokogiri will collapse a single element array into the response hash.
628
+ ############################################################################################################
629
+ def messages_to_array(response)
630
+ if not response[:messages].nil?
631
+ return response
632
+ end
633
+ # add the messages array to the response - if we got here, there was only one error.
634
+ response[:messages] = [{
635
+ :summary => response[:summary],
636
+ :details => response[:details],
637
+ :helplink => response[:helplink],
638
+ :refersto => response[:refersto],
639
+ :severity => response[:severity],
640
+ :source => response[:source]
641
+ }]
642
+ #remove all the error information from the hash
643
+ response[:messages][0].each do |k,v|
644
+ response.delete(k)
645
+ end
646
+ return response
625
647
  end
626
-
627
648
  end
628
649
  end
@@ -15,7 +15,7 @@ svc = AvaTax::TaxService.new(:username => credentials['username'],
15
15
  :doctype=>"SalesInvoice", #Required
16
16
  :docid=> "", #Optional
17
17
  :detaillevel=>"Tax", #Optional
18
- :debug => false #Optional
18
+ :debug => true #Optional
19
19
  }
20
20
  #Call the service
21
21
  result = svc.gettaxhistory(request)
@@ -2,4 +2,4 @@ username: username
2
2
  password: password
3
3
  clientname: AvaTaxCalcSOAP Ruby Sample
4
4
  production: false
5
- companycode: APITrialCompany
5
+ companycode: 1
@@ -167,7 +167,9 @@ describe "AdjustTax" do
167
167
  @creds[:password] = nil
168
168
  @service = AvaTax::TaxService.new(@creds)
169
169
  @result = @service.adjusttax(@request_required)
170
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
170
+ @result[:result_code].should eql "Error" and
171
+ @result[:messages].kind_of?(Array).should eql true and
172
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
171
173
  end
172
174
  it "successful results" do
173
175
  @service = AvaTax::TaxService.new(@creds)
@@ -74,7 +74,9 @@ describe "CancelTax" do
74
74
  @creds[:password] = nil
75
75
  @service = AvaTax::TaxService.new(@creds)
76
76
  @result = @service.canceltax(@request_required)
77
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
77
+ @result[:result_code].should eql "Error" and
78
+ @result[:messages].kind_of?(Array).should eql true and
79
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
78
80
  end
79
81
  it "successful results" do
80
82
  @service = AvaTax::TaxService.new(@creds)
@@ -85,7 +85,9 @@ describe "CommitTax" do
85
85
  @creds[:password] = nil
86
86
  @service = AvaTax::TaxService.new(@creds)
87
87
  @result = @service.committax(@request_required)
88
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
88
+ @result[:result_code].should eql "Error" and
89
+ @result[:messages].kind_of?(Array).should eql true and
90
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
89
91
  end
90
92
  it "successful results" do
91
93
  @service = AvaTax::TaxService.new(@creds)
data/spec/gettax_spec.rb CHANGED
@@ -149,7 +149,9 @@ describe "GetTax" do
149
149
  @creds[:password] = nil
150
150
  @service = AvaTax::TaxService.new(@creds)
151
151
  @result = @service.gettax(@request_required)
152
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
152
+ @result[:result_code].should eql "Error" and
153
+ @result[:messages].kind_of?(Array).should eql true and
154
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
153
155
  end
154
156
  it "successful results" do
155
157
  @service = AvaTax::TaxService.new(@creds)
@@ -74,7 +74,9 @@ describe "GetTaxHistory" do
74
74
  @creds[:password] = nil
75
75
  @service = AvaTax::TaxService.new(@creds)
76
76
  @result = @service.gettaxhistory(@request_required)
77
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
77
+ @result[:result_code].should eql "Error" and
78
+ @result[:messages].kind_of?(Array).should eql true and
79
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
78
80
  end
79
81
  it "successful results" do
80
82
  @service = AvaTax::TaxService.new(@creds)
@@ -46,7 +46,9 @@ describe "IsAuthorized" do
46
46
  @creds[:password] = nil
47
47
  @service = AvaTax::TaxService.new(@creds)
48
48
  @result = @service.isauthorized
49
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
49
+ @result[:result_code].should eql "Error" and
50
+ @result[:messages].kind_of?(Array).should eql true and
51
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
50
52
  end
51
53
  it "successful results" do
52
54
  @service = AvaTax::TaxService.new(@creds)
data/spec/ping_spec.rb CHANGED
@@ -46,7 +46,9 @@ describe "Ping" do
46
46
  @creds[:password] = nil
47
47
  @service = AvaTax::TaxService.new(@creds)
48
48
  @result = @service.ping
49
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
49
+ @result[:result_code].should eql "Error" and
50
+ @result[:messages].kind_of?(Array).should eql true and
51
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
50
52
  end
51
53
  it "successful results" do
52
54
  @service = AvaTax::TaxService.new(@creds)
data/spec/posttax_spec.rb CHANGED
@@ -84,7 +84,9 @@ describe "PostTax" do
84
84
  @creds[:password] = nil
85
85
  @service = AvaTax::TaxService.new(@creds)
86
86
  @result = @service.posttax(@request_required)
87
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
87
+ @result[:result_code].should eql "Error" and
88
+ @result[:messages].kind_of?(Array).should eql true and
89
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
88
90
  end
89
91
  it "successful results" do
90
92
  @service = AvaTax::TaxService.new(@creds)
@@ -78,7 +78,9 @@ describe "ReconcileTaxHistory" do
78
78
  @creds[:password] = nil
79
79
  @service = AvaTax::TaxService.new(@creds)
80
80
  @result = @service.reconciletaxhistory(@request_required)
81
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
81
+ @result[:result_code].should eql "Error" and
82
+ @result[:messages].kind_of?(Array).should eql true and
83
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
82
84
  end
83
85
  it "successful results" do
84
86
  @service = AvaTax::TaxService.new(@creds)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Avatax_TaxService
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.12
4
+ version: 1.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham S Wilson