Avatax_TaxService 1.0.14 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/Avatax_TaxService.gemspec +22 -22
- data/LICENSE.txt +20 -20
- data/lib/avatax_taxservice.rb +643 -648
- data/lib/tax_log.txt +1 -0
- data/lib/{taxservice_dev.wsdl → taxservice.wsdl} +1090 -1090
- data/lib/template_adjusttax.erb +98 -98
- data/lib/template_canceltax.erb +30 -30
- data/lib/template_committax.erb +30 -30
- data/lib/template_gettax.erb +94 -94
- data/lib/template_gettaxhistory.erb +27 -27
- data/lib/template_isauthorized.erb +21 -21
- data/lib/template_ping.erb +21 -21
- data/lib/template_posttax.erb +32 -32
- data/lib/template_reconciletaxhistory.erb +31 -31
- data/samples/CancelTaxTest.rb +33 -33
- data/samples/GetTaxHistoryTest.rb +44 -44
- data/samples/GetTaxTest.rb +148 -148
- data/samples/PingTest.rb +25 -25
- data/samples/PostTaxTest.rb +39 -39
- data/spec/adjusttax_spec.rb +236 -236
- data/spec/canceltax_spec.rb +149 -149
- data/spec/committax_spec.rb +146 -146
- data/spec/gettax_spec.rb +279 -279
- data/spec/gettaxhistory_spec.rb +121 -121
- data/spec/isauthorized_spec.rb +76 -76
- data/spec/ping_spec.rb +76 -76
- data/spec/posttax_spec.rb +170 -170
- data/spec/reconciletaxhistory_spec.rb +126 -126
- data/spec/spec_helper.rb +15 -15
- data/spec/taxservice_spec.rb +41 -41
- metadata +14 -17
- data/Avatax Ruby SDK Guide.docx +0 -0
- data/lib/taxservice_prd.wsdl +0 -1091
- data/samples/ValidateAddressTest.rb +0 -50
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
NmIyODBhY2JiNGI4MDY1OTVkZjY2MGE3ZjJlZWU0OWYyZDVjZjE5Yw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: dda65b810670689ee2629eca1585245fcb36ed93
|
4
|
+
data.tar.gz: a1fcc662b18825625ca427210f495ba519c7d46d
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Y2YxZTI0NDE2NTJkMmVhZTI1ZGExYjY1ZjNlMDlhNDA1MTAxYTJlM2M2ODBm
|
11
|
-
YmEzMzhiMTQwMjFmMDExNTFkMWRhMDI5YzNkNTM3NWIwNjkxZGE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NzA5ZmIxMjVmMzY3ODNiZTVlNDI0MTJjMGUxOTkwMjEzMGMxMzA5ZWY5ODI2
|
14
|
-
MTdjMDMyMWY4NjU5NTRkYWRiOGM4M2RlMmVkNzc3ZGExODM1MGRmYjUwMzNl
|
15
|
-
M2ZkZGI5NWRiZGIxZmMzNmI3MDBmMjNmOTEwNGRlOGNmYzk4YjY=
|
6
|
+
metadata.gz: e30884fe83ad03f7ee8819f6004be5a3ae6a4ecc25a74bcc603838155a6527a915143a4d10f0793f271f6fc608bd83d728d776fb67f422bdcc9d30b68f2913ac
|
7
|
+
data.tar.gz: 00f3190776f769af80fc2cc4c7c1f3af84e0d43013b001f8ca36ca6f4101235afe7e2453054c0c359963f48e6323087f87e0025b49eae1ab702101cde0e5abfe
|
data/Avatax_TaxService.gemspec
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = "Avatax_TaxService"
|
3
|
-
s.version = "
|
4
|
-
s.date = "
|
5
|
-
s.author = "Graham S Wilson"
|
6
|
-
s.email = "support@Avalara.com"
|
7
|
-
s.summary = "Avatax SDK for Ruby "
|
8
|
-
s.homepage = "http://www.avalara.com/"
|
9
|
-
s.description = "Ruby SDK provides means of communication with Avatax Web Services."
|
10
|
-
s.license = 'MIT'
|
11
|
-
s.files = ["lib/tax_log.txt", "lib/
|
12
|
-
"lib/template_adjusttax.erb", "lib/template_canceltax.erb", "lib/template_committax.erb","lib/template_gettax.erb",
|
13
|
-
"lib/template_gettaxhistory.erb","lib/template_isauthorized.erb","lib/template_ping.erb","lib/template_posttax.erb",
|
14
|
-
"lib/template_reconciletaxhistory.erb",
|
15
|
-
"samples/CancelTaxTest.rb","samples/GetTaxTest.rb","samples/GetTaxHistoryTest.rb","samples/PingTest.rb","samples/PostTaxTest.rb",
|
16
|
-
"spec/adjusttax_spec.rb","spec/canceltax_spec.rb","spec/committax_spec.rb","spec/gettax_spec.rb",
|
17
|
-
"spec/gettaxhistory_spec.rb","spec/isauthorized_spec.rb","spec/ping_spec.rb","spec/posttax_spec.rb","spec/reconciletaxhistory_spec.rb",
|
18
|
-
"spec/spec_helper.rb","spec/taxservice_spec.rb","Avatax_TaxService.gemspec","
|
19
|
-
s.add_dependency "savon", ">= 2.3.0"
|
20
|
-
s.required_ruby_version = '>= 1.9.1'
|
21
|
-
s.post_install_message = 'Thanks for installing the Avalara TaxService Ruby SDK.
|
22
|
-
end
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "Avatax_TaxService"
|
3
|
+
s.version = "2.0.1"
|
4
|
+
s.date = "2015-06-12"
|
5
|
+
s.author = "Graham S Wilson"
|
6
|
+
s.email = "support@Avalara.com"
|
7
|
+
s.summary = "Avatax SDK for Ruby "
|
8
|
+
s.homepage = "http://www.avalara.com/"
|
9
|
+
s.description = "Ruby SDK provides means of communication with Avatax Web Services."
|
10
|
+
s.license = 'MIT'
|
11
|
+
s.files = ["lib/tax_log.txt", "lib/taxservice.wsdl", "lib/avatax_taxservice.rb",
|
12
|
+
"lib/template_adjusttax.erb", "lib/template_canceltax.erb", "lib/template_committax.erb","lib/template_gettax.erb",
|
13
|
+
"lib/template_gettaxhistory.erb","lib/template_isauthorized.erb","lib/template_ping.erb","lib/template_posttax.erb",
|
14
|
+
"lib/template_reconciletaxhistory.erb",
|
15
|
+
"samples/CancelTaxTest.rb","samples/GetTaxTest.rb","samples/GetTaxHistoryTest.rb","samples/PingTest.rb","samples/PostTaxTest.rb",
|
16
|
+
"spec/adjusttax_spec.rb","spec/canceltax_spec.rb","spec/committax_spec.rb","spec/gettax_spec.rb",
|
17
|
+
"spec/gettaxhistory_spec.rb","spec/isauthorized_spec.rb","spec/ping_spec.rb","spec/posttax_spec.rb","spec/reconciletaxhistory_spec.rb",
|
18
|
+
"spec/spec_helper.rb","spec/taxservice_spec.rb","Avatax_TaxService.gemspec","LICENSE.txt"]
|
19
|
+
s.add_dependency "savon", ">= 2.3.0"
|
20
|
+
s.required_ruby_version = '>= 1.9.1'
|
21
|
+
s.post_install_message = 'Thanks for installing the Avalara TaxService Ruby SDK. For more information and to sign up for a free test account, visit http://developer.avalara.com'
|
22
|
+
end
|
23
23
|
|
data/LICENSE.txt
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
Ruby SDK for AvaTax [License]
|
2
|
-
Copyright (c) 2013 Avalara Inc.
|
3
|
-
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
a copy of this software and associated documentation files (the
|
6
|
-
"Software"), to deal in the Software without restriction, including
|
7
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
Ruby SDK for AvaTax [License]
|
2
|
+
Copyright (c) 2013 Avalara Inc.
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
21
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/avatax_taxservice.rb
CHANGED
@@ -1,649 +1,644 @@
|
|
1
|
-
require 'savon'
|
2
|
-
require 'erb'
|
3
|
-
require 'benchmark'
|
4
|
-
|
5
|
-
module AvaTax
|
6
|
-
#Avalara tax class
|
7
|
-
class TaxService
|
8
|
-
def initialize(credentials)
|
9
|
-
|
10
|
-
#Retrieve gemspec details
|
11
|
-
spec = Gem::Specification.find_by_name("Avatax_TaxService")
|
12
|
-
#Set @def_locn to the Avatax-x.x.x gem install library. This enables the ruby programs to
|
13
|
-
#find other objects that it needs.
|
14
|
-
gem_root = spec.gem_dir
|
15
|
-
@def_locn = gem_root + "/lib"
|
16
|
-
|
17
|
-
|
18
|
-
username = credentials[:username]
|
19
|
-
password = credentials[:password]
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
@
|
32
|
-
@
|
33
|
-
@
|
34
|
-
@
|
35
|
-
@
|
36
|
-
@
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
#
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
@
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
@
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
@
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
@
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
@
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
@
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
@log.puts "
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
@
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
#
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
@
|
183
|
-
@
|
184
|
-
@
|
185
|
-
@
|
186
|
-
@
|
187
|
-
@
|
188
|
-
|
189
|
-
|
190
|
-
@
|
191
|
-
@
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
@
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
@log.puts "
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
@
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
@
|
263
|
-
@
|
264
|
-
@
|
265
|
-
@
|
266
|
-
@
|
267
|
-
@
|
268
|
-
|
269
|
-
|
270
|
-
@
|
271
|
-
@
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
@
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
@log.puts "
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
@
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
#
|
341
|
-
@
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
@log.puts "
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
@
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
#
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
@log.puts "
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
@
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
#
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
@log.puts "
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
@
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
@log.puts "
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
@
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
@
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
@log.puts "
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
@
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
@
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
@
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
:
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
response.delete(k)
|
645
|
-
end
|
646
|
-
return response
|
647
|
-
end
|
648
|
-
end
|
1
|
+
require 'savon'
|
2
|
+
require 'erb'
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
module AvaTax
|
6
|
+
#Avalara tax class
|
7
|
+
class TaxService
|
8
|
+
def initialize(credentials)
|
9
|
+
|
10
|
+
#Retrieve gemspec details
|
11
|
+
spec = Gem::Specification.find_by_name("Avatax_TaxService")
|
12
|
+
#Set @def_locn to the Avatax-x.x.x gem install library. This enables the ruby programs to
|
13
|
+
#find other objects that it needs.
|
14
|
+
gem_root = spec.gem_dir
|
15
|
+
@def_locn = "../lib"#gem_root + "/lib"
|
16
|
+
|
17
|
+
#Extract data from hash
|
18
|
+
username = credentials[:username] || ""
|
19
|
+
password = credentials[:password] || ""
|
20
|
+
service_url = credentials[:service_url]
|
21
|
+
if service_url.nil? or service_url.empty?
|
22
|
+
raise ArgumentError, "service_url is required"
|
23
|
+
end
|
24
|
+
name = credentials[:name] || ""
|
25
|
+
clientname = (credentials[:clientname].nil? or credentials[:clientname].empty? ) ? "AvataxRubySDK" : credentials[:clientname]
|
26
|
+
adapter = (credentials[:adapter].nil? or credentials[:adapter].empty?) ? spec.summary + spec.version.to_s : credentials[:adapter]
|
27
|
+
machine = credentials[:machine] || ""
|
28
|
+
|
29
|
+
|
30
|
+
#Set credentials and Profile information
|
31
|
+
@username = username
|
32
|
+
@password = password
|
33
|
+
@name = name
|
34
|
+
@clientname = clientname
|
35
|
+
@adapter = adapter
|
36
|
+
@machine = machine
|
37
|
+
|
38
|
+
#Header for response data
|
39
|
+
@responsetime_hdr = " (User) (System) (Total) (Real)"
|
40
|
+
|
41
|
+
#Open Avatax Error Log
|
42
|
+
@log = File.new(@def_locn + '/tax_log.txt', "w")
|
43
|
+
|
44
|
+
#Get service details from WSDL - control_array[2] contains the WSDL read from the address_control file
|
45
|
+
#log :false turns off HTTP logging. Select either Dev or Prod depending on the value of the boolean value 'use_production_account'
|
46
|
+
@log.puts "#{Time.now}: Avalara Tax service started"
|
47
|
+
@client = Savon.client(wsdl: @def_locn + '/taxservice.wsdl', endpoint: URI.parse(service_url+"/Address/AddressSvc.asmx"), log: false)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
#Read in the SOAP template for Get tax
|
52
|
+
begin
|
53
|
+
@template_gettax = ERB.new(File.read(@def_locn + '/template_gettax.erb'))
|
54
|
+
rescue
|
55
|
+
@log.puts "#{Time.now}: Error loading the GetTax template"
|
56
|
+
end
|
57
|
+
|
58
|
+
#Read in the SOAP template for Adjust tax
|
59
|
+
begin
|
60
|
+
@template_adjust = ERB.new(File.read(@def_locn + '/template_adjusttax.erb'))
|
61
|
+
rescue
|
62
|
+
@log.puts "#{Time.now}: Error loading the AdjustTax template"
|
63
|
+
end
|
64
|
+
|
65
|
+
#Read in the SOAP template for Ping
|
66
|
+
begin
|
67
|
+
@template_ping = ERB.new(File.read(@def_locn + '/template_ping.erb'))
|
68
|
+
rescue
|
69
|
+
@log.puts "#{Time.now}: Error loading the Ping template"
|
70
|
+
end
|
71
|
+
|
72
|
+
#Read in the SOAP template for IsAuthorized
|
73
|
+
begin
|
74
|
+
@template_isauthorized = ERB.new(File.read(@def_locn + '/template_isauthorized.erb'))
|
75
|
+
rescue
|
76
|
+
@log.puts "#{Time.now}: Error loading the IsAuthorized template"
|
77
|
+
end
|
78
|
+
|
79
|
+
#Read in the SOAP template for Tax
|
80
|
+
begin
|
81
|
+
@template_post = ERB.new(File.read(@def_locn + '/template_posttax.erb'))
|
82
|
+
rescue
|
83
|
+
@log.puts "#{Time.now}: Error loading the Post template"
|
84
|
+
end
|
85
|
+
|
86
|
+
#Read in the SOAP template for Commit tax
|
87
|
+
begin
|
88
|
+
@template_commit = ERB.new(File.read(@def_locn + '/template_committax.erb'))
|
89
|
+
rescue
|
90
|
+
@log.puts "#{Time.now}: Error loading the CommitTax template"
|
91
|
+
end
|
92
|
+
|
93
|
+
#Read in the SOAP template for Cancel tax
|
94
|
+
begin
|
95
|
+
@template_cancel = ERB.new(File.read(@def_locn + '/template_canceltax.erb'))
|
96
|
+
rescue
|
97
|
+
@log.puts "#{Time.now}: Error loading the CancelTax template"
|
98
|
+
end
|
99
|
+
|
100
|
+
#Read in the SOAP template for GetTaxHistory tax
|
101
|
+
begin
|
102
|
+
@template_gettaxhistory = ERB.new(File.read(@def_locn + '/template_gettaxhistory.erb'))
|
103
|
+
rescue
|
104
|
+
@log.puts "#{Time.now}: Error loading the GetTaxHistory template"
|
105
|
+
end
|
106
|
+
|
107
|
+
#Read in the SOAP template for GetTaxHistory tax
|
108
|
+
begin
|
109
|
+
@template_reconciletaxhistory = ERB.new(File.read(@def_locn + '/template_reconciletaxhistory.erb'))
|
110
|
+
rescue
|
111
|
+
@log.puts "#{Time.now}: Error loading the ReconcileTaxHistory template"
|
112
|
+
end
|
113
|
+
|
114
|
+
# Create hash for validate result
|
115
|
+
@response = Hash.new
|
116
|
+
end
|
117
|
+
|
118
|
+
####################################################################################################
|
119
|
+
# ping - Verifies connectivity to the web service and returns version information about the service.
|
120
|
+
####################################################################################################
|
121
|
+
def ping(message = nil)
|
122
|
+
|
123
|
+
@service = 'Ping'
|
124
|
+
|
125
|
+
#Read in the SOAP template
|
126
|
+
@message = message == nil ? "?" : message
|
127
|
+
|
128
|
+
# Subsitute real vales for template place holders
|
129
|
+
@soap = @template_ping.result(binding)
|
130
|
+
if @debug
|
131
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
132
|
+
@log.puts @soap
|
133
|
+
end
|
134
|
+
|
135
|
+
# Make the call to the Avalara service
|
136
|
+
begin
|
137
|
+
# Call using debug
|
138
|
+
if @debug
|
139
|
+
# Use Ruby built in Benchmark function to record response times
|
140
|
+
@log.puts "#{Time.now}: Calling #{@service} Service"
|
141
|
+
time = Benchmark.measure do
|
142
|
+
# Call Ping Service
|
143
|
+
@response = @client.call(:ping, xml: @soap).to_hash
|
144
|
+
end
|
145
|
+
@log.puts "Response times for Ping:"
|
146
|
+
@log.puts @responsetime_hdr
|
147
|
+
@log.puts time
|
148
|
+
else
|
149
|
+
# Call Ping Service
|
150
|
+
@response = @client.call(:ping, xml: @soap).to_hash
|
151
|
+
end
|
152
|
+
|
153
|
+
#Strip off outer layer of the hash - not needed
|
154
|
+
@response = messages_to_array(@response[:ping_response][:ping_result])
|
155
|
+
|
156
|
+
return @response
|
157
|
+
|
158
|
+
#Capture unexpected errors
|
159
|
+
rescue Savon::Error => error
|
160
|
+
abend(error)
|
161
|
+
end
|
162
|
+
|
163
|
+
end
|
164
|
+
|
165
|
+
####################################################################################################
|
166
|
+
# gettax - Calls the Avatax GetTax Service
|
167
|
+
####################################################################################################
|
168
|
+
def gettax(document)
|
169
|
+
|
170
|
+
@service = 'GetTax'
|
171
|
+
|
172
|
+
#create instance variables for each entry in input
|
173
|
+
document.each do |k,v|
|
174
|
+
instance_variable_set("@#{k}",v)
|
175
|
+
end
|
176
|
+
#set required default values for missing required inputs
|
177
|
+
@doctype ||= "SalesOrder"
|
178
|
+
@discount ||= "0"
|
179
|
+
@detaillevel ||= "Tax"
|
180
|
+
@commit ||= false
|
181
|
+
@servicemode ||= "Remote"
|
182
|
+
@paymentdate ||= "1900-01-01"
|
183
|
+
@exchangerate ||= "0"
|
184
|
+
@exchangerateeffdate ||= "1900-01-01"
|
185
|
+
@taxoverridetype ||= "None"
|
186
|
+
@taxamount ||= "0"
|
187
|
+
@taxdate ||= "1900-01-01"
|
188
|
+
|
189
|
+
#set required values for some fields
|
190
|
+
@hashcode = "0"
|
191
|
+
@batchcode = ""
|
192
|
+
|
193
|
+
|
194
|
+
#@addresses
|
195
|
+
@addresses.each do |addr|
|
196
|
+
addr[:taxregionid] ||= "0"
|
197
|
+
end
|
198
|
+
#@lines
|
199
|
+
@lines.each do |line|
|
200
|
+
line[:taxoverridetypeline] ||= "None"
|
201
|
+
line[:taxamountline] ||= "0"
|
202
|
+
line[:taxdateline] ||= "1900-01-01"
|
203
|
+
line[:discounted] ||= false
|
204
|
+
line[:taxincluded] ||= false
|
205
|
+
end
|
206
|
+
|
207
|
+
# Subsitute template place holders with real values
|
208
|
+
@soap = @template_gettax.result(binding)
|
209
|
+
# If in debug mode write SOAP request to log
|
210
|
+
if @debug
|
211
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
212
|
+
@log.puts @soap
|
213
|
+
end
|
214
|
+
|
215
|
+
# Make the call to the Avalara service
|
216
|
+
begin
|
217
|
+
# Call using debug
|
218
|
+
if @debug
|
219
|
+
# Use Ruby built in Benchmark function to record response times
|
220
|
+
@log.puts "#{Time.now}: Calling GetTax Service for DocCode: #{@doccode}"
|
221
|
+
time = Benchmark.measure do
|
222
|
+
# Call GetTax Service
|
223
|
+
@response = @client.call(:get_tax, xml: @soap).to_hash
|
224
|
+
end
|
225
|
+
@log.puts "Response times for GetTax:"
|
226
|
+
@log.puts @responsetime_hdr
|
227
|
+
@log.puts time
|
228
|
+
else
|
229
|
+
# Call GetTax Service
|
230
|
+
@response = @client.call(:get_tax, xml: @soap).to_hash
|
231
|
+
end
|
232
|
+
|
233
|
+
#Strip off outer layer of the hash - not needed
|
234
|
+
@response = messages_to_array(@response[:get_tax_response][:get_tax_result])
|
235
|
+
|
236
|
+
#Return data to calling program
|
237
|
+
return @response
|
238
|
+
|
239
|
+
#Capture unexpected errors
|
240
|
+
rescue Savon::Error => error
|
241
|
+
abend(error)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
####################################################################################################
|
246
|
+
# adjusttax - Calls the Avatax AdjustTax Service
|
247
|
+
####################################################################################################
|
248
|
+
def adjusttax(document)
|
249
|
+
|
250
|
+
@service = 'AdjustTax'
|
251
|
+
|
252
|
+
#create instance variables for each entry in input
|
253
|
+
document.each do |k,v|
|
254
|
+
instance_variable_set("@#{k}",v)
|
255
|
+
end
|
256
|
+
#set required default values for missing required inputs
|
257
|
+
@doctype ||= "SalesOrder"
|
258
|
+
@discount ||= "0"
|
259
|
+
@detaillevel ||= "Tax"
|
260
|
+
@commit ||= false
|
261
|
+
@servicemode ||= "Remote"
|
262
|
+
@paymentdate ||= "1900-01-01"
|
263
|
+
@exchangerate ||= "0"
|
264
|
+
@exchangerateeffdate ||= "1900-01-01"
|
265
|
+
@taxoverridetype ||= "None"
|
266
|
+
@taxamount ||= "0"
|
267
|
+
@taxdate ||= "1900-01-01"
|
268
|
+
|
269
|
+
#set required values for some fields
|
270
|
+
@hashcode = "0"
|
271
|
+
@batchcode = ""
|
272
|
+
|
273
|
+
|
274
|
+
#@addresses
|
275
|
+
@addresses.each do |addr|
|
276
|
+
addr[:taxregionid] ||= "0"
|
277
|
+
end
|
278
|
+
#@lines
|
279
|
+
@lines.each do |line|
|
280
|
+
line[:taxoverridetypeline] ||= "None"
|
281
|
+
line[:taxamountline] ||= "0"
|
282
|
+
line[:taxdateline] ||= "1900-01-01"
|
283
|
+
line[:discounted] ||= false
|
284
|
+
line[:taxincluded] ||= false
|
285
|
+
end
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
# Subsitute template place holders with real values
|
290
|
+
@soap = @template_adjust.result(binding)
|
291
|
+
if @debug
|
292
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
293
|
+
@log.puts @soap
|
294
|
+
end
|
295
|
+
|
296
|
+
# Make the call to the Avalara service
|
297
|
+
begin
|
298
|
+
# Call using debug
|
299
|
+
if @debug
|
300
|
+
# Use Ruby built in Benchmark function to record response times
|
301
|
+
@log.puts "#{Time.now}: Calling AdjustTax Service for DocCode: #{@doccode}"
|
302
|
+
time = Benchmark.measure do
|
303
|
+
# Call AdjustTax Service
|
304
|
+
@response = @client.call(:adjust_tax, xml: @soap).to_hash
|
305
|
+
end
|
306
|
+
@log.puts "Response times for AdjustTax:"
|
307
|
+
@log.puts @responsetime_hdr
|
308
|
+
@log.puts time
|
309
|
+
else
|
310
|
+
# Call AdjustTax Service
|
311
|
+
@response = @client.call(:adjust_tax, xml: @soap).to_hash
|
312
|
+
end
|
313
|
+
|
314
|
+
#Strip off outer layer of the hash - not needed
|
315
|
+
return messages_to_array(@response[:adjust_tax_response][:adjust_tax_result])
|
316
|
+
|
317
|
+
#Capture unexpected errors
|
318
|
+
rescue Savon::Error => error
|
319
|
+
abend(error)
|
320
|
+
end
|
321
|
+
|
322
|
+
end
|
323
|
+
|
324
|
+
####################################################################################################
|
325
|
+
# posttax - Calls the Avatax PostTax Service
|
326
|
+
####################################################################################################
|
327
|
+
def posttax(document)
|
328
|
+
|
329
|
+
@service = 'PostTax'
|
330
|
+
|
331
|
+
#create instance variables for each entry in input
|
332
|
+
document.each do |k,v|
|
333
|
+
instance_variable_set("@#{k}",v)
|
334
|
+
end
|
335
|
+
#set required default values for missing required inputs
|
336
|
+
@hashcode = "0"
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
# Subsitute template place holders with real values
|
341
|
+
@soap = @template_post.result(binding)
|
342
|
+
if @debug
|
343
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
344
|
+
@log.puts @soap
|
345
|
+
end
|
346
|
+
|
347
|
+
# Make the call to the Avalara service
|
348
|
+
begin
|
349
|
+
# Call using debug
|
350
|
+
if @debug
|
351
|
+
# Use Ruby built in Benchmark function to record response times
|
352
|
+
@log.puts "#{Time.now}: Calling PostTax Service for DocCode: #{@doccode}"
|
353
|
+
time = Benchmark.measure do
|
354
|
+
# Call PostTax Service
|
355
|
+
@response = @client.call(:post_tax, xml: @soap).to_hash
|
356
|
+
end
|
357
|
+
@log.puts "Response times for PostTax:"
|
358
|
+
@log.puts @responsetime_hdr
|
359
|
+
@log.puts time
|
360
|
+
else
|
361
|
+
# Call PostTax Service
|
362
|
+
@response = @client.call(:post_tax, xml: @soap).to_hash
|
363
|
+
end
|
364
|
+
|
365
|
+
#Strip off outer layer of the hash - not needed
|
366
|
+
#Return data to calling program
|
367
|
+
return messages_to_array(@response[:post_tax_response][:post_tax_result])
|
368
|
+
|
369
|
+
#Capture unexpected errors
|
370
|
+
rescue Savon::Error => error
|
371
|
+
abend(error)
|
372
|
+
end
|
373
|
+
|
374
|
+
end
|
375
|
+
|
376
|
+
####################################################################################################
|
377
|
+
# committax - Calls the Avatax CommitTax Service
|
378
|
+
####################################################################################################
|
379
|
+
def committax(document)
|
380
|
+
|
381
|
+
@service = 'CommitTax'
|
382
|
+
|
383
|
+
#create instance variables for each entry in input
|
384
|
+
document.each do |k,v|
|
385
|
+
instance_variable_set("@#{k}",v)
|
386
|
+
end
|
387
|
+
#set required default values for missing required inputs
|
388
|
+
#no required default values exist for committax
|
389
|
+
|
390
|
+
# Subsitute template place holders with real values
|
391
|
+
@soap = @template_commit.result(binding)
|
392
|
+
if @debug
|
393
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
394
|
+
@log.puts @soap
|
395
|
+
end
|
396
|
+
|
397
|
+
# Make the call to the Avalara service
|
398
|
+
begin
|
399
|
+
# Call using debug
|
400
|
+
if @debug
|
401
|
+
# Use Ruby built in Benchmark function to record response times
|
402
|
+
@log.puts "#{Time.now}: Calling CommitTax Service for DocCode: #{@doccode}"
|
403
|
+
time = Benchmark.measure do
|
404
|
+
# Call CommitTax Service
|
405
|
+
@response = @client.call(:commit_tax, xml: @soap).to_hash
|
406
|
+
end
|
407
|
+
@log.puts "Response times for CommitTax:"
|
408
|
+
@log.puts @responsetime_hdr
|
409
|
+
@log.puts time
|
410
|
+
else
|
411
|
+
# Call CommitTax Service
|
412
|
+
@response = @client.call(:commit_tax, xml: @soap).to_hash
|
413
|
+
end
|
414
|
+
|
415
|
+
#Strip off outer layer of the hash - not needed
|
416
|
+
#Return data to calling program
|
417
|
+
return messages_to_array(@response[:commit_tax_response][:commit_tax_result])
|
418
|
+
|
419
|
+
#Capture unexpected errors
|
420
|
+
rescue Savon::Error => error
|
421
|
+
abend(error)
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
####################################################################################################
|
426
|
+
# canceltax - Calls the Avatax CancelTax Service
|
427
|
+
####################################################################################################
|
428
|
+
def canceltax(document)
|
429
|
+
|
430
|
+
@service = 'CancelTax'
|
431
|
+
|
432
|
+
#create instance variables for each entry in input
|
433
|
+
document.each do |k,v|
|
434
|
+
instance_variable_set("@#{k}",v)
|
435
|
+
end
|
436
|
+
#set required default values for missing required inputs
|
437
|
+
#no required default values exist for canceltax
|
438
|
+
|
439
|
+
# Subsitute template place holders with real values
|
440
|
+
@soap = @template_cancel.result(binding)
|
441
|
+
if @debug
|
442
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
443
|
+
@log.puts @soap
|
444
|
+
end
|
445
|
+
|
446
|
+
# Make the call to the Avalara service
|
447
|
+
begin
|
448
|
+
# Call using debug
|
449
|
+
if @debug
|
450
|
+
# Use Ruby built in Benchmark function to record response times
|
451
|
+
@log.puts "#{Time.now}: Calling CancelTax Service for DocCode: #{@doccode}"
|
452
|
+
time = Benchmark.measure do
|
453
|
+
# Call CancelTax Service
|
454
|
+
@response = @client.call(:cancel_tax, xml: @soap).to_hash
|
455
|
+
end
|
456
|
+
@log.puts "Response times for CancelTax:"
|
457
|
+
@log.puts @responsetime_hdr
|
458
|
+
@log.puts time
|
459
|
+
else
|
460
|
+
# Call CancelTax Service
|
461
|
+
@response = @client.call(:cancel_tax, xml: @soap).to_hash
|
462
|
+
end
|
463
|
+
|
464
|
+
#Strip off outer layer of the hash - not needed
|
465
|
+
return messages_to_array(@response[:cancel_tax_response][:cancel_tax_result])
|
466
|
+
|
467
|
+
#Capture unexpected errors
|
468
|
+
rescue Savon::Error => error
|
469
|
+
abend(error)
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
####################################################################################################
|
474
|
+
# gettaxhistory - Calls the Avatax GetTaxHistory Service
|
475
|
+
####################################################################################################
|
476
|
+
def gettaxhistory(document)
|
477
|
+
|
478
|
+
@service = 'GetTaxHistory'
|
479
|
+
|
480
|
+
#create instance variables for each entry in input
|
481
|
+
document.each do |k,v|
|
482
|
+
instance_variable_set("@#{k}",v)
|
483
|
+
end
|
484
|
+
#set required default values for missing required inputs
|
485
|
+
@detaillevel ||= "Tax"
|
486
|
+
|
487
|
+
# Subsitute template place holders with real values
|
488
|
+
@soap = @template_gettaxhistory.result(binding)
|
489
|
+
if @debug
|
490
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
491
|
+
@log.puts @soap
|
492
|
+
end
|
493
|
+
|
494
|
+
# Make the call to the Avalara service
|
495
|
+
begin
|
496
|
+
# Call using debug
|
497
|
+
if @debug
|
498
|
+
# Use Ruby built in Benchmark function to record response times
|
499
|
+
@log.puts "#{Time.now}: Calling GetTaxHistory Service"
|
500
|
+
time = Benchmark.measure do
|
501
|
+
# Call GetTaxHistory Service
|
502
|
+
@response = @client.call(:get_tax_history, xml: @soap).to_hash
|
503
|
+
end
|
504
|
+
@log.puts "Response times for GetTaxHistory:"
|
505
|
+
@log.puts @responsetime_hdr
|
506
|
+
@log.puts time
|
507
|
+
else
|
508
|
+
# Call GetTaxHistory Service
|
509
|
+
@response = @client.call(:get_tax_history, xml: @soap).to_hash
|
510
|
+
end
|
511
|
+
|
512
|
+
#Strip off outer layer of the hash - not needed
|
513
|
+
return messages_to_array(@response[:get_tax_history_response][:get_tax_history_result])
|
514
|
+
|
515
|
+
|
516
|
+
#Capture unexpected errors
|
517
|
+
rescue Savon::Error => error
|
518
|
+
abend(error)
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
####################################################################################################
|
523
|
+
# reconciletaxhistory - Calls the Avatax ReconcileTaxHistory Service
|
524
|
+
####################################################################################################
|
525
|
+
def reconciletaxhistory(document)
|
526
|
+
|
527
|
+
|
528
|
+
@service = 'ReconcileTaxHistory'
|
529
|
+
|
530
|
+
#create instance variables for each entry in input
|
531
|
+
document.each do |k,v|
|
532
|
+
instance_variable_set("@#{k}",v)
|
533
|
+
end
|
534
|
+
#set required default values for missing required inputs
|
535
|
+
@pagesize ||= "100"
|
536
|
+
@reconciled ||= false
|
537
|
+
@doctype ||= "SalesInvoice"
|
538
|
+
@docstatus ||= "Any"
|
539
|
+
@lastdoccode ||= ''
|
540
|
+
|
541
|
+
|
542
|
+
|
543
|
+
# Subsitute template place holders with real values
|
544
|
+
@soap = @template_reconciletaxhistory.result(binding)
|
545
|
+
if @debug
|
546
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
547
|
+
@log.puts @soap
|
548
|
+
end
|
549
|
+
|
550
|
+
# Make the call to the Avalara service
|
551
|
+
begin
|
552
|
+
# Call using debug
|
553
|
+
if @debug
|
554
|
+
# Use Ruby built in Benchmark function to record response times
|
555
|
+
@log.puts "#{Time.now}: Calling ReconcileTaxHistory Service"
|
556
|
+
time = Benchmark.measure do
|
557
|
+
# Call ReconcileTaxHistory Service
|
558
|
+
@response = @client.call(:reconcile_tax_history, xml: @soap).to_hash
|
559
|
+
end
|
560
|
+
@log.puts "Response times for ReconcileTaxHistory:"
|
561
|
+
@log.puts @responsetime_hdr
|
562
|
+
@log.puts time
|
563
|
+
else
|
564
|
+
# Call ReconcileTaxHistory Service
|
565
|
+
@response = @client.call(:reconcile_tax_history, xml: @soap).to_hash
|
566
|
+
end
|
567
|
+
|
568
|
+
#Strip off outer layer of the hash - not needed
|
569
|
+
return messages_to_array(@response[:reconcile_tax_history_response][:reconcile_tax_history_result])
|
570
|
+
|
571
|
+
#Capture unexpected errors
|
572
|
+
rescue Savon::Error => error
|
573
|
+
abend(error)
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
############################################################################################################
|
578
|
+
# isauthorized - Verifies connectivity to the web service and returns expiry information about the service.
|
579
|
+
############################################################################################################
|
580
|
+
def isauthorized(operation = nil)
|
581
|
+
|
582
|
+
@service = 'IsAuthorized'
|
583
|
+
|
584
|
+
#Read in the SOAP template
|
585
|
+
@operation = operation == nil ? "?" : operation
|
586
|
+
|
587
|
+
# Subsitute real vales for template place holders
|
588
|
+
@soap = @template_isauthorized.result(binding)
|
589
|
+
if @debug
|
590
|
+
@log.puts "#{Time.now}: SOAP request created:"
|
591
|
+
@log.puts @soap
|
592
|
+
end
|
593
|
+
|
594
|
+
# Make the call to the Avalara service
|
595
|
+
begin
|
596
|
+
@response = @client.call(:is_authorized, xml: @soap).to_hash
|
597
|
+
|
598
|
+
#Strip off outer layer of the hash - not needed
|
599
|
+
return messages_to_array(@response[:is_authorized_response][:is_authorized_result])
|
600
|
+
|
601
|
+
#Capture unexpected errors
|
602
|
+
rescue Savon::Error => error
|
603
|
+
abend(error)
|
604
|
+
end
|
605
|
+
end
|
606
|
+
|
607
|
+
private
|
608
|
+
|
609
|
+
############################################################################################################
|
610
|
+
# abend - Unexpected error handling
|
611
|
+
############################################################################################################
|
612
|
+
def abend(error)
|
613
|
+
@log.puts "An unexpected error occurred: Response from server = #{error}"
|
614
|
+
@log.puts "#{Time.now}: Error calling #{@service} service ... check that your account name and password are correct."
|
615
|
+
@response = error.to_hash
|
616
|
+
@response[:result_code] = 'Error'
|
617
|
+
@response[:summary] = @response[:fault][:faultcode]
|
618
|
+
@response[:details] = @response[:fault][:faultstring]
|
619
|
+
return messages_to_array(@response)
|
620
|
+
end
|
621
|
+
############################################################################################################
|
622
|
+
#standardizes error message format to an array of messages - nokogiri will collapse a single element array into the response hash.
|
623
|
+
############################################################################################################
|
624
|
+
def messages_to_array(response)
|
625
|
+
if not response[:messages].nil?
|
626
|
+
return response
|
627
|
+
end
|
628
|
+
# add the messages array to the response - if we got here, there was only one error.
|
629
|
+
response[:messages] = [{
|
630
|
+
:summary => response[:summary],
|
631
|
+
:details => response[:details],
|
632
|
+
:helplink => response[:helplink],
|
633
|
+
:refersto => response[:refersto],
|
634
|
+
:severity => response[:severity],
|
635
|
+
:source => response[:source]
|
636
|
+
}]
|
637
|
+
#remove all the error information from the hash
|
638
|
+
response[:messages][0].each do |k,v|
|
639
|
+
response.delete(k)
|
640
|
+
end
|
641
|
+
return response
|
642
|
+
end
|
643
|
+
end
|
649
644
|
end
|