Avatax_AddressService 1.0.8 → 1.0.9
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 +8 -8
- data/Avatax_AddressService.gemspec +2 -2
- data/lib/avatax_addressservice.rb +22 -41
- metadata +1 -2
- data/test/test_address.rb +0 -176
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGEwYzJmYWVhMzM0NmYwNTY3ZTVhMWE3M2I0ZWEwM2IxYzljZWJmZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWYxNjI5NGE3NTg1N2MwOWNiNjQzY2IzZDdhMTBiNjNkNDRmNmRkOQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmM5NjliYjk2ODAyYWFlN2VmZDE5ZjEyZDhmNzIyMTY4MzBlNTdhYTdkZDM5
|
10
|
+
MmI1ZTQwNjM0NzVkMjg5MzNkNTVjZTdlMzBjYWJkOTYxMWExZmY1ZjVlNmMz
|
11
|
+
ZDI1YmEzOTM5YTQ3MjFjYzAyNjljMjgyNjZiZGIxYTJhZThiNmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWY3MGE2YTdlN2RkODIyNmEyZjMwZTg3OTQ2NWRhZTBmZTU1M2JlMGI5NGM0
|
14
|
+
ZGJmYTA5MzlkZTQxNDhjNDJkZThlODI1YzZkYWZiMjc2YjBiMmM1NThkNDUx
|
15
|
+
N2I5NTFjMDFiMjJjYWI1NzdjNmQxNDNjMGFkYmZmMGM3MjQ0NzA=
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "Avatax_AddressService"
|
3
|
-
s.version = "1.0.
|
3
|
+
s.version = "1.0.9"
|
4
4
|
s.date = "2012-12-16"
|
5
5
|
s.author = "Graham S Wilson"
|
6
6
|
s.email = "support@Avalara.com"
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.license = 'MIT'
|
10
10
|
s.description = "Ruby SDK provides means of communication with Avatax Web Services."
|
11
11
|
s.files = ["lib/address_log.txt", "lib/addressservice_dev.wsdl", "lib/addressservice_prd.wsdl", "lib/avatax_addressservice.rb",
|
12
|
-
"lib/template_validate.erb","lib/template_ping.erb","lib/template_isauthorized.erb",
|
12
|
+
"lib/template_validate.erb","lib/template_ping.erb","lib/template_isauthorized.erb",
|
13
13
|
"Avatax_AddressService.gemspec", "Avatax Ruby SDK Guide.docx", "LICENSE.txt"]
|
14
14
|
# s.add_dependency "nokogiri", ">= 1.4.0", "< 1.6"
|
15
15
|
s.add_dependency "savon", ">= 2.3.0"
|
@@ -14,7 +14,10 @@ module AvaTax
|
|
14
14
|
|
15
15
|
#Extract data from hash
|
16
16
|
username = credentials[:username]
|
17
|
-
password = credentials[:password]
|
17
|
+
password = credentials[:password]
|
18
|
+
if username.nil? and password.nil?
|
19
|
+
raise ArgumentError, "username and password are required"
|
20
|
+
end
|
18
21
|
name = credentials[:name]
|
19
22
|
clientname = credentials[:clientname]
|
20
23
|
adapter = credentials[:adapter]
|
@@ -25,7 +28,7 @@ module AvaTax
|
|
25
28
|
@username = username == nil ? "" : username
|
26
29
|
@password = password == nil ? "" : password
|
27
30
|
@name = name == nil ? "" : name
|
28
|
-
@clientname = (clientname == nil or clientname == "") ? "
|
31
|
+
@clientname = (clientname == nil or clientname == "") ? "AvataxRubySDK" : clientname
|
29
32
|
@adapter = (adapter == nil or adapter == "") ? spec.summary + spec.version.to_s : adapter
|
30
33
|
@machine = machine == nil ? "" : machine
|
31
34
|
@use_production_account = (use_production_account != true) ? false : use_production_account
|
@@ -73,7 +76,7 @@ module AvaTax
|
|
73
76
|
############################################################################################################
|
74
77
|
# ping - Verifies connectivity to the web service and returns version information
|
75
78
|
############################################################################################################
|
76
|
-
def ping(message)
|
79
|
+
def ping(message = nil)
|
77
80
|
|
78
81
|
@service = 'Ping'
|
79
82
|
|
@@ -88,7 +91,7 @@ module AvaTax
|
|
88
91
|
@response = @client.call(:ping, xml: @soap).to_hash
|
89
92
|
|
90
93
|
#Strip off outer layer of the hash - not needed
|
91
|
-
@response = @response[:ping_response]
|
94
|
+
@response = @response[:ping_response][:ping_result]
|
92
95
|
|
93
96
|
return @response
|
94
97
|
|
@@ -104,40 +107,18 @@ module AvaTax
|
|
104
107
|
def validate(address)
|
105
108
|
|
106
109
|
@service = 'Validate'
|
107
|
-
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
longitude = address[:longitude]
|
120
|
-
textcase = address[:textcase]
|
121
|
-
coordinates = address[:coordinates]
|
122
|
-
taxability = address[:taxability]
|
123
|
-
|
124
|
-
#Set parms passed by user - If Nil then default else use passed value
|
125
|
-
@addresscode = addresscode == nil ? "123" : addresscode
|
126
|
-
@line1 = line1 == nil ? "" : line1
|
127
|
-
@line2 = line2 == nil ? "" : line2
|
128
|
-
@line3 = line3 == nil ? "" : line3
|
129
|
-
@city = city == nil ? "" : city
|
130
|
-
@region = region == nil ? "" : region
|
131
|
-
@postalcode = postalcode == nil ? "" : postalcode
|
132
|
-
@country = country == nil ? "" : country
|
133
|
-
@taxregionid = taxregionid == nil ? "0" : taxregionid
|
134
|
-
@latitude = latitude == nil ? "" : latitude
|
135
|
-
@longitude = longitude == nil ? "" : longitude
|
136
|
-
@textcase = textcase == nil ? "Default" : textcase
|
137
|
-
@coordinates = coordinates == nil ? "true" : coordinates
|
138
|
-
@taxability = taxability == nil ? "false" : taxability
|
139
|
-
|
140
|
-
# Subsitute real vales for template place holders
|
110
|
+
|
111
|
+
#create instance variables for each entry in input
|
112
|
+
address.each do |k,v|
|
113
|
+
instance_variable_set("@#{k}",v)
|
114
|
+
end
|
115
|
+
#set required default values for missing required inputs
|
116
|
+
@taxregionid ||= "0"
|
117
|
+
@textcase ||= "Default"
|
118
|
+
@coordinates ||= false
|
119
|
+
@taxability ||= false
|
120
|
+
|
121
|
+
# Subsitute real values for template place holders
|
141
122
|
@soap = @template_validate.result(binding)
|
142
123
|
|
143
124
|
# Make the call to the Avalara Validate service
|
@@ -145,7 +126,7 @@ module AvaTax
|
|
145
126
|
@response = @client.call(:validate, xml: @soap).to_hash
|
146
127
|
|
147
128
|
#Strip off outer layer of the hash - not needed
|
148
|
-
@response = @response[:validate_response]
|
129
|
+
@response = @response[:validate_response][:validate_result]
|
149
130
|
|
150
131
|
#Return data to calling program
|
151
132
|
return @response
|
@@ -159,7 +140,7 @@ module AvaTax
|
|
159
140
|
############################################################################################################
|
160
141
|
#Verifies connectivity to the web service and returns version information about the service.
|
161
142
|
############################################################################################################
|
162
|
-
def isauthorized(operation)
|
143
|
+
def isauthorized(operation = nil)
|
163
144
|
|
164
145
|
@service = 'IsAuthorized'
|
165
146
|
|
@@ -174,7 +155,7 @@ module AvaTax
|
|
174
155
|
@response = @client.call(:is_authorized, xml: @soap).to_hash
|
175
156
|
|
176
157
|
#Strip off outer layer of the hash - not needed
|
177
|
-
@response = @response[:is_authorized_response]
|
158
|
+
@response = @response[:is_authorized_response][:is_authorized_result]
|
178
159
|
|
179
160
|
return @response
|
180
161
|
|
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.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Graham S Wilson
|
@@ -37,7 +37,6 @@ files:
|
|
37
37
|
- lib/template_validate.erb
|
38
38
|
- lib/template_ping.erb
|
39
39
|
- lib/template_isauthorized.erb
|
40
|
-
- test/test_address.rb
|
41
40
|
- Avatax_AddressService.gemspec
|
42
41
|
- Avatax Ruby SDK Guide.docx
|
43
42
|
- LICENSE.txt
|
data/test/test_address.rb
DELETED
@@ -1,176 +0,0 @@
|
|
1
|
-
#Load the Avalara Address Service module
|
2
|
-
require 'avatax_addressservice'
|
3
|
-
#require green_shoes for the GUI
|
4
|
-
require 'green_shoes'
|
5
|
-
|
6
|
-
#Create new Credentials hash object
|
7
|
-
credentials = Hash.new
|
8
|
-
|
9
|
-
#Create new Address hash object
|
10
|
-
address = Hash.new
|
11
|
-
val_addr = Hash.new
|
12
|
-
|
13
|
-
Shoes.app :width => 400, :height => 460 do
|
14
|
-
background orange
|
15
|
-
border("#BE8",
|
16
|
-
strokewidth: 6)
|
17
|
-
stack(margin: 15) do
|
18
|
-
para
|
19
|
-
para "Enter Avalara credentials"
|
20
|
-
para "Username:"
|
21
|
-
@username = edit_line text: "USERNAME"
|
22
|
-
para "Password:"
|
23
|
-
@password = edit_line text: "PASSWORD", :secret => true
|
24
|
-
para "Test Production:"
|
25
|
-
@use_production_account = edit_line text: "false"
|
26
|
-
para
|
27
|
-
@confirm = button "Confirm"
|
28
|
-
para
|
29
|
-
@confirm.click {
|
30
|
-
credentials[:username] = @username.text
|
31
|
-
credentials[:password] = @password.text
|
32
|
-
credentials[:name] = 'Avalara Inc.'
|
33
|
-
credentials[:clientname] = ''
|
34
|
-
credentials[:adapter] = ''
|
35
|
-
credentials[:machine] = 'Lenovo W520 Windows 7'
|
36
|
-
if @use_production_account.text == 'true' then
|
37
|
-
credentials[:use_production_account] = !!@use_production_account
|
38
|
-
else
|
39
|
-
credentials[:use_production_account] = nil
|
40
|
-
end
|
41
|
-
|
42
|
-
#Create an address service instance
|
43
|
-
AddrService = AvaTax::AddressService.new(credentials)
|
44
|
-
|
45
|
-
#Open a window to get the address to validate
|
46
|
-
Shoes.app :width => 400, :height => 700, :title => "Avalara - Address Validation Tester" do
|
47
|
-
|
48
|
-
#Set window characteristics
|
49
|
-
background green..orange
|
50
|
-
|
51
|
-
#Get the address to validate from the user
|
52
|
-
stack :margin => 10 do
|
53
|
-
#Get user input
|
54
|
-
para "Line 1:"
|
55
|
-
@line1 = edit_line text: "100 rav"
|
56
|
-
para "Line 2:"
|
57
|
-
@line2 = edit_line
|
58
|
-
para "Line 3:"
|
59
|
-
@line3 = edit_line
|
60
|
-
para "City"
|
61
|
-
@city = edit_line width: 100, text: "bainbridge"
|
62
|
-
para "State"
|
63
|
-
@state = edit_line width: 40, text: 'WA'
|
64
|
-
para "Zip"
|
65
|
-
@zip = edit_line width: 60, text: "98110"
|
66
|
-
para "Country"
|
67
|
-
@country = edit_line width: 30, text: "US"
|
68
|
-
para "Textcase"
|
69
|
-
@textcase = "Default"
|
70
|
-
list_box items: ["Default", "Upper", "Mixed"],
|
71
|
-
width: 120, choose: @textcase do |list|
|
72
|
-
@textcase = list.text
|
73
|
-
end
|
74
|
-
@validate = button "Validate"
|
75
|
-
end
|
76
|
-
|
77
|
-
#When the user clicks the Validate button then call the Validate service
|
78
|
-
@validate.click {
|
79
|
-
address[:line1] = @line1.text
|
80
|
-
address[:line2] = @line2.text
|
81
|
-
address[:line3] = @line3.text
|
82
|
-
address[:city] = @city.text
|
83
|
-
address[:region] = @state.text
|
84
|
-
address[:postalcode] = @zip.text
|
85
|
-
address[:country]= @country.text
|
86
|
-
address[:textcase] = @textcase
|
87
|
-
address[:addresscode] = "123"
|
88
|
-
|
89
|
-
|
90
|
-
#Call the validate service - passing the address as a Hash
|
91
|
-
val_addr = AddrService.validate(address)
|
92
|
-
|
93
|
-
#if val_addr[:validate_result][:result_code] == "Success" and val_addr[:result_code] != "Error"
|
94
|
-
if val_addr[:result_code] == "Error"
|
95
|
-
|
96
|
-
Shoes.app :width => 400, :height => 500, :margin => 10, :title => "Address Validation Error" do
|
97
|
-
|
98
|
-
background orange..red
|
99
|
-
|
100
|
-
#Dispay error details
|
101
|
-
para "RESULT: Error"
|
102
|
-
para "DETAILS #{val_addr[:details]}"
|
103
|
-
end
|
104
|
-
else
|
105
|
-
if val_addr[:validate_result][:result_code] == "Success"
|
106
|
-
|
107
|
-
#Display validated result in a new window
|
108
|
-
Shoes.app :width => 400, :height => 1000, :left => 1000, :title => "Avalara - Address Validation Result" do
|
109
|
-
|
110
|
-
background orange..blue
|
111
|
-
|
112
|
-
stack :margin => 10 do
|
113
|
-
#Display result
|
114
|
-
para "Line 1:"
|
115
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:line1]
|
116
|
-
para "Line 2:"
|
117
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:line2]
|
118
|
-
para "Line 3:"
|
119
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:line3]
|
120
|
-
para "City"
|
121
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:city]
|
122
|
-
para "State"
|
123
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:region]
|
124
|
-
para "Zip"
|
125
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:postal_code]
|
126
|
-
para "Country"
|
127
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:country]
|
128
|
-
para
|
129
|
-
para "Latitude"
|
130
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:latitude]
|
131
|
-
para "Longitude"
|
132
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:longitude]
|
133
|
-
para "County"
|
134
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:county]
|
135
|
-
para "FIPS Code"
|
136
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:fips_code]
|
137
|
-
para "Carrier Route"
|
138
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:carrier_route]
|
139
|
-
para "Post Net"
|
140
|
-
edit_line :text => val_addr[:validate_result][:valid_addresses][:valid_address][:post_net]
|
141
|
-
end
|
142
|
-
end
|
143
|
-
else
|
144
|
-
|
145
|
-
#Display error message in a new window
|
146
|
-
Shoes.app :width => 400, :height => 500, :title => "Address Validation Error" do
|
147
|
-
|
148
|
-
background orange..red
|
149
|
-
|
150
|
-
if val_addr[:validate_result][:result_code] == "Error"
|
151
|
-
|
152
|
-
stack :margin => 10 do
|
153
|
-
#Dispay error details
|
154
|
-
para "RESULT: #{val_addr[:validate_result][:result_code]}"
|
155
|
-
para "SUMMARY: #{val_addr[:validate_result][:messages][:message][:summary]}"
|
156
|
-
para "DETAILS: #{val_addr[:validate_result][:messages][:message][:details]}"
|
157
|
-
para "HELP LINK: #{val_addr[:validate_result][:messages][:message][:help_link]}"
|
158
|
-
para "REFERS TO: #{val_addr[:validate_result][:messages][:message][:refers_to]}"
|
159
|
-
para "SEVERITY: #{val_addr[:validate_result][:messages][:message][:severity]}"
|
160
|
-
para "SOURCE #{val_addr[:validate_result][:messages][:message][:source]}"
|
161
|
-
end
|
162
|
-
else
|
163
|
-
#Dispay error details
|
164
|
-
para "RESULT: Error"
|
165
|
-
para "SUMMARY: Unexpected error"
|
166
|
-
para "DETAILS: An unexpected error has occurred ... please check address_log.txt for details"
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end}
|
171
|
-
end}
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
|
176
|
-
|