Avatax_AddressService 1.0.2 → 1.0.3

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.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Avatax_AddressService"
3
- s.version = "1.0.2"
3
+ s.version = "1.0.3"
4
4
  s.date = "2012-10-28"
5
5
  s.author = "Graham S Wilson"
6
6
  s.email = "support@Avalara.com"
@@ -18,9 +18,11 @@ module AvaTax
18
18
  @machine = machine == nil ? "" : machine
19
19
 
20
20
  #Set @def_locn to the Avatax-x.x.x gem install library. This enables the ruby programs to
21
- #find other objects that it needs.
22
- @def_locn = 'C:\Ruby193\lib\ruby\gems\1.9.1\gems\Avatax_AddressService-1.0.0\lib'
23
-
21
+ #find other objects that it needs.
22
+ spec = Gem::Specification.find_by_name("Avatax_AddressService")
23
+ gem_root = spec.gem_dir
24
+ @def_locn = gem_root + "/lib"
25
+
24
26
  #Open Avatax Error Log
25
27
  @log = File.new(@def_locn + '\address_log.txt', "w")
26
28
  @log.puts "#{Time.now}: Address service started"
@@ -1,105 +1,119 @@
1
- #Load the Avalara Address Service module
1
+ #Load the Avalara Address Service module
2
2
  require 'avatax_addressservice'
3
3
  #require green_shoes for the GUI
4
4
  require 'green_shoes'
5
5
 
6
- #Create an address service instance
7
- #Call the gettax service
8
- username = 'USERNAME
9
- password = 'PASSWORD'
10
- name = 'Avalara Inc.'
11
- clientname = 'MyShoppingCart'
12
- adapter = 'Avatax SDK for Ruby 1.0.1'
13
- machine = 'Lenovo W520 Windows 7'
14
- AddrService = AvaTax::AddressService.new(username,password,name,clientname,adapter,machine)
15
-
16
- #Open a window to get the address to validate
17
- Shoes.app :width => 400, :height => 700, :title => "Avalara - Address Validation Tester" do
18
-
19
- #Set window characteristics
20
- background green..orange
21
-
22
- #Get the address to validate from the user
23
- stack :margin => 10 do
24
- #Get user input
25
- para "Line 1:"
26
- @line1 = edit_line text: "100 rav"
27
- para "Line 2:"
28
- @line2 = edit_line
29
- para "Line 3:"
30
- @line3 = edit_line
31
- para "City"
32
- @city = edit_line width: 100, text: "bainbridge"
33
- para "State"
34
- @state = edit_line width: 40, text: 'WA'
35
- para "Zip"
36
- @zip = edit_line width: 60, text: "98110"
37
- para "Country"
38
- @country = edit_line width: 30, text: "US"
39
- para "Textcase"
40
- @textcase = "Default"
41
- list_box items: ["Default", "Upper", "Mixed"],
42
- width: 120, choose: @textcase do |list|
43
- @textcase = list.text
44
- end
45
- @validate = button "Validate"
46
- end
6
+ Shoes.app :width => 400, :height => 400 do
7
+ background orange
8
+ border("#BE8",
9
+ strokewidth: 6)
10
+ stack(margin: 15) do
11
+ para
12
+ para "Enter Avalara credentials"
13
+ para "Username:"
14
+ @username = edit_line
15
+ para "Password:"
16
+ @password = edit_line :secret => true
17
+ para
18
+ @confirm = button "Confirm"
19
+ para
20
+ @confirm.click {
21
+ name = 'Avalara Inc.'
22
+ clientname = 'MyShoppingCart'
23
+ adapter = 'Avatax SDK for Ruby 1.0.1'
24
+ machine = 'Lenovo W520 Windows 7'
25
+ #Create an address service instance
26
+ AddrService = AvaTax::AddressService.new(@username.text,@password.text,name,clientname,adapter,machine)
47
27
 
48
-
49
- #When the user clicks the Validate button then call the Validate service
50
- @validate.click {
51
-
52
- #Call the validate service
53
- val_addr = AddrService.validate(nil, @line1.text, nil, nil, @city.text, @state.text, @zip.text, 'US', nil, nil, nil, @textcase, nil, nil)
54
-
55
- if val_addr[:ResultCode] == "Success"
56
- #Display validated result in a new window
57
- Shoes.app :width => 400, :height => 700, :left => 1000, :title => "Avalara - Address Validation Result" do
58
-
59
- background orange..blue
60
-
61
- stack :margin => 10 do
62
- #Display result
28
+ #Open a window to get the address to validate
29
+ Shoes.app :width => 400, :height => 700, :title => "Avalara - Address Validation Tester" do
30
+
31
+ #Set window characteristics
32
+ background green..orange
33
+
34
+ #Get the address to validate from the user
35
+ stack :margin => 10 do
36
+ #Get user input
63
37
  para "Line 1:"
64
- edit_line :text => val_addr[:Line1]
38
+ @line1 = edit_line text: "100 rav"
65
39
  para "Line 2:"
66
- edit_line :text => val_addr[:Line2]
40
+ @line2 = edit_line
67
41
  para "Line 3:"
68
- edit_line :text => val_addr[:Line3]
42
+ @line3 = edit_line
69
43
  para "City"
70
- edit_line :text => val_addr[:City]
44
+ @city = edit_line width: 100, text: "bainbridge"
71
45
  para "State"
72
- edit_line :text => val_addr[:Region]
73
- para "Zip"
74
- edit_line :text => val_addr[:PostalCode]
46
+ @state = edit_line width: 40, text: 'WA'
47
+ para "Zip"
48
+ @zip = edit_line width: 60, text: "98110"
75
49
  para "Country"
76
- edit_line :text => val_addr[:Country]
50
+ @country = edit_line width: 30, text: "US"
51
+ para "Textcase"
52
+ @textcase = "Default"
53
+ list_box items: ["Default", "Upper", "Mixed"],
54
+ width: 120, choose: @textcase do |list|
55
+ @textcase = list.text
56
+ end
57
+ @validate = button "Validate"
77
58
  end
78
- end
79
- else
80
- #Display error message in a new window
81
- Shoes.app :width => 400, :height => 500, :title => "Address Validation Error" do
59
+
60
+ #When the user clicks the Validate button then call the Validate service
61
+ @validate.click {
62
+
63
+
64
+ #Call the validate service
65
+ val_addr = AddrService.validate(nil, @line1.text, nil, nil, @city.text, @state.text, @zip.text, 'US', nil, nil, nil, @textcase, nil, nil)
66
+
67
+
68
+ if val_addr[:ResultCode] == "Success"
69
+ #Display validated result in a new window
70
+ Shoes.app :width => 400, :height => 700, :left => 1000, :title => "Avalara - Address Validation Result" do
82
71
 
83
- background orange..red
84
-
85
- if val_addr[:ResultCode] == "Error"
86
- stack :margin => 10 do
87
- #Dispay error details
88
- para "RESULT: #{val_addr[:ResultCode]}"
89
- para "SUMMARY: #{val_addr[:Summary]}"
90
- para "DETAILS: #{val_addr[:Details]}"
91
- para "HELP LINK: #{val_addr[:Helplink]}"
92
- para "REFERS TO: #{val_addr[:RefersTo]}"
93
- para "SEVERITY: #{val_addr[:Severity]}"
94
- para "SOURCE #{val_addr[:Source]}"
95
- end
72
+ background orange..blue
73
+
74
+ stack :margin => 10 do
75
+ #Display result
76
+ para "Line 1:"
77
+ edit_line :text => val_addr[:Line1]
78
+ para "Line 2:"
79
+ edit_line :text => val_addr[:Line2]
80
+ para "Line 3:"
81
+ edit_line :text => val_addr[:Line3]
82
+ para "City"
83
+ edit_line :text => val_addr[:City]
84
+ para "State"
85
+ edit_line :text => val_addr[:Region]
86
+ para "Zip"
87
+ edit_line :text => val_addr[:PostalCode]
88
+ para "Country"
89
+ edit_line :text => val_addr[:Country]
90
+ end
91
+ end
96
92
  else
97
- #Dispay error details
98
- para "RESULT: Error"
99
- para "SUMMARY: Unexpected error"
100
- para "DETAILS: An unexpected error has occurred ... please check avalog.txt for details"
101
- end
102
- end
103
- end}
93
+ #Display error message in a new window
94
+ Shoes.app :width => 400, :height => 500, :title => "Address Validation Error" do
95
+
96
+ background orange..red
97
+
98
+ if val_addr[:ResultCode] == "Error"
99
+ stack :margin => 10 do
100
+ #Dispay error details
101
+ para "RESULT: #{val_addr[:ResultCode]}"
102
+ para "SUMMARY: #{val_addr[:Summary]}"
103
+ para "DETAILS: #{val_addr[:Details]}"
104
+ para "HELP LINK: #{val_addr[:Helplink]}"
105
+ para "REFERS TO: #{val_addr[:RefersTo]}"
106
+ para "SEVERITY: #{val_addr[:Severity]}"
107
+ para "SOURCE #{val_addr[:Source]}"
108
+ end
109
+ else
110
+ #Dispay error details
111
+ para "RESULT: Error"
112
+ para "SUMMARY: Unexpected error"
113
+ para "DETAILS: An unexpected error has occurred ... please check address_log.txt for details"
114
+ end
115
+ end
116
+ end}
117
+ end}
118
+ end
104
119
  end
105
-
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.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: