Avatax_AddressService 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Avatax_AddressService.gemspec +1 -1
- data/lib/avatax_addressservice.rb +28 -10
- data/samples/credentials.yml +1 -1
- data/spec/isauthorized_spec.rb +4 -2
- data/spec/ping_spec.rb +3 -1
- data/spec/validate_spec.rb +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjllZjY5OTY0NGE2OGM3ZGM5ZDI1ZmQ4MDVkOTc2NjI2NzZjZTU1MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTIyYzQzYjIwYmI4NTI5MmY0NjY4MzRiNGU3NjU5MTE5YmZjYjU1YQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZiZjFiODAyMTU0YzFmOWZkYTY0NzUyOTM0MTM1MWYzMzFhMDc2Zjg3YmVm
|
10
|
+
N2RiMzk4MGEzNGExNmNiY2I1NmJmOWI5NmYxZTdmYTIxNDg5OTJhNjU0MzQ0
|
11
|
+
MzQwOWZmNTcyMWI1YzUyYmMxZTg1YjQxY2Q4YzgwNTM3MjM3OWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODczZTE5NDY5NTAzMDgwNjg5MGE5ZTU3YTBkZTE2YmYzMjliNGI3NzJjYzQ5
|
14
|
+
MzdhZWMwNGE5ZWIyMzhiMjJhOTAwMjZiNDg4YzQ5MjU0NjRlZjJhYjc2ZTVm
|
15
|
+
MWU1N2I2MjNhZTVmYjE2MjJhYThiOTgyNzVkZDFiYmY4MjcyYmE=
|
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/samples/credentials.yml
CHANGED
data/spec/isauthorized_spec.rb
CHANGED
@@ -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
|
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
|
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/validate_spec.rb
CHANGED
@@ -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
|
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)
|