Avatax_AddressService 1.0.10 → 1.0.11

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
- ZDE0YjRhNzgxMDVmY2M2MDQ1YTRmYjdhOTFhZTMzNjM0ODdlZTAwYw==
4
+ YjllZjY5OTY0NGE2OGM3ZGM5ZDI1ZmQ4MDVkOTc2NjI2NzZjZTU1MQ==
5
5
  data.tar.gz: !binary |-
6
- ZjkyYmJjYjc0YjJlYzVjMzAwMmEwNjZjMmIxNzZmYTYyNDQ0YjczYg==
6
+ NTIyYzQzYjIwYmI4NTI5MmY0NjY4MzRiNGU3NjU5MTE5YmZjYjU1YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWI4NjkyOGFkMzJjMGNmYmJjNWVhYjVkMmE3ZjBhNDRhZmRjZjM0MjI3OTA0
10
- MDFkNmYwYzVkNDc5MGYzZTczM2Y2YmE4MjJjM2FlYmQ0NWVjMWUwYjU0MjBl
11
- MGUyOGUzYmU3ZjNiMzY3NzE2MWFlZmY0MWU3MWNjZjRhYWFjM2I=
9
+ ZDZiZjFiODAyMTU0YzFmOWZkYTY0NzUyOTM0MTM1MWYzMzFhMDc2Zjg3YmVm
10
+ N2RiMzk4MGEzNGExNmNiY2I1NmJmOWI5NmYxZTdmYTIxNDg5OTJhNjU0MzQ0
11
+ MzQwOWZmNTcyMWI1YzUyYmMxZTg1YjQxY2Q4YzgwNTM3MjM3OWU=
12
12
  data.tar.gz: !binary |-
13
- NmUzODk2NWE3NWYwOGNiYTU4MGMyNmNhNTVhMWFmYTdlYzU1NTVkMzU5OGNl
14
- NmY1MTkwNDNlMGY1NDNmNmQxMWRhODM0YWIzZjdiYmNhMmQwYjc5ZTQ5ZWM1
15
- NjlhNTY2OWMwMTFlMzVhYjdlMzAzN2ZmZTg0ZWJkOGM1MjA1YTk=
13
+ ODczZTE5NDY5NTAzMDgwNjg5MGE5ZTU3YTBkZTE2YmYzMjliNGI3NzJjYzQ5
14
+ MzdhZWMwNGE5ZWIyMzhiMjJhOTAwMjZiNDg4YzQ5MjU0NjRlZjJhYjc2ZTVm
15
+ MWU1N2I2MjNhZTVmYjE2MjJhYThiOTgyNzVkZDFiYmY4MjcyYmE=
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Avatax_AddressService"
3
- s.version = "1.0.10"
3
+ s.version = "1.0.11"
4
4
  s.date = "2012-12-16"
5
5
  s.author = "Graham S Wilson"
6
6
  s.email = "support@Avalara.com"
@@ -91,9 +91,8 @@ module AvaTax
91
91
  @response = @client.call(:ping, xml: @soap).to_hash
92
92
 
93
93
  #Strip off outer layer of the hash - not needed
94
- @response = @response[:ping_response][:ping_result]
94
+ return messages_to_array(@response[:ping_response][:ping_result])
95
95
 
96
- return @response
97
96
 
98
97
  #Capture unexpected errors
99
98
  rescue Savon::Error => error
@@ -126,10 +125,8 @@ module AvaTax
126
125
  @response = @client.call(:validate, xml: @soap).to_hash
127
126
 
128
127
  #Strip off outer layer of the hash - not needed
129
- @response = @response[:validate_response][:validate_result]
130
-
131
- #Return data to calling program
132
- return @response
128
+ return messages_to_array(@response[:validate_response][:validate_result])
129
+
133
130
 
134
131
  #Capture unexpected errors
135
132
  rescue Savon::Error => error
@@ -155,9 +152,7 @@ module AvaTax
155
152
  @response = @client.call(:is_authorized, xml: @soap).to_hash
156
153
 
157
154
  #Strip off outer layer of the hash - not needed
158
- @response = @response[:is_authorized_response][:is_authorized_result]
159
-
160
- return @response
155
+ return messages_to_array(@response[:is_authorized_response][:is_authorized_result])
161
156
 
162
157
  #Capture unexpected errors
163
158
  rescue Savon::Error => error
@@ -176,7 +171,30 @@ module AvaTax
176
171
  @response[:result_code] = 'Error'
177
172
  @response[:summary] = @response[:fault][:faultcode]
178
173
  @response[:details] = @response[:fault][:faultstring]
179
- return @response
174
+ return messages_to_array(@response)
175
+ end
176
+
177
+ ############################################################################################################
178
+ #standardizes error message format to an array of messages - nokogiri will collapse a single element array into the response hash.
179
+ ############################################################################################################
180
+ def messages_to_array(response)
181
+ if not response[:messages].nil?
182
+ return response
183
+ end
184
+ # add the messages array to the response - if we got here, there was only one error.
185
+ response[:messages] = [{
186
+ :summary => response[:summary],
187
+ :details => response[:details],
188
+ :helplink => response[:helplink],
189
+ :refersto => response[:refersto],
190
+ :severity => response[:severity],
191
+ :source => response[:source]
192
+ }]
193
+ #remove all the error information from the hash
194
+ response[:messages][0].each do |k,v|
195
+ response.delete(k)
196
+ end
197
+ return response
180
198
  end
181
199
  end
182
200
  end
@@ -1,4 +1,4 @@
1
- username: username
1
+ username: username
2
2
  password: password
3
3
  clientname: AvaTaxCalcSOAP Ruby Sample
4
4
  production: false
@@ -23,7 +23,7 @@ describe "IsAuthorized" do
23
23
  it "error when username is missing" do
24
24
  @creds[:username] = nil
25
25
  @service = AvaTax::AddressService.new(@creds)
26
- @service.isauthorized[:result_code].should eql "Error"
26
+ @service.isauthorized[:result_code].should eql "Error"
27
27
  end
28
28
  it "error when password is omitted" do
29
29
  @creds[:password] = nil
@@ -46,7 +46,9 @@ describe "IsAuthorized" do
46
46
  @creds[:password] = nil
47
47
  @service = AvaTax::AddressService.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::AddressService.new(@creds)
data/spec/ping_spec.rb CHANGED
@@ -46,7 +46,9 @@ describe "Ping" do
46
46
  @creds[:password] = nil
47
47
  @service = AvaTax::AddressService.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::AddressService.new(@creds)
@@ -60,7 +60,9 @@ describe "Validate" do
60
60
  @creds[:password] = nil
61
61
  @service = AvaTax::AddressService.new(@creds)
62
62
  @result = @service.validate(@address_req)
63
- @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
63
+ @result[:result_code].should eql "Error" and
64
+ @result[:messages].kind_of?(Array).should eql true and
65
+ @result[:messages][0].should include(:details => "The user or account could not be authenticated.")
64
66
  end
65
67
  it "successful results" do
66
68
  @result = @svc.validate(@address_req)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Avatax_AddressService
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham S Wilson