Avatax_AddressService 1.0.9 → 1.0.10

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
- NGEwYzJmYWVhMzM0NmYwNTY3ZTVhMWE3M2I0ZWEwM2IxYzljZWJmZA==
4
+ ZDE0YjRhNzgxMDVmY2M2MDQ1YTRmYjdhOTFhZTMzNjM0ODdlZTAwYw==
5
5
  data.tar.gz: !binary |-
6
- YWYxNjI5NGE3NTg1N2MwOWNiNjQzY2IzZDdhMTBiNjNkNDRmNmRkOQ==
6
+ ZjkyYmJjYjc0YjJlYzVjMzAwMmEwNjZjMmIxNzZmYTYyNDQ0YjczYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MmM5NjliYjk2ODAyYWFlN2VmZDE5ZjEyZDhmNzIyMTY4MzBlNTdhYTdkZDM5
10
- MmI1ZTQwNjM0NzVkMjg5MzNkNTVjZTdlMzBjYWJkOTYxMWExZmY1ZjVlNmMz
11
- ZDI1YmEzOTM5YTQ3MjFjYzAyNjljMjgyNjZiZGIxYTJhZThiNmM=
9
+ ZWI4NjkyOGFkMzJjMGNmYmJjNWVhYjVkMmE3ZjBhNDRhZmRjZjM0MjI3OTA0
10
+ MDFkNmYwYzVkNDc5MGYzZTczM2Y2YmE4MjJjM2FlYmQ0NWVjMWUwYjU0MjBl
11
+ MGUyOGUzYmU3ZjNiMzY3NzE2MWFlZmY0MWU3MWNjZjRhYWFjM2I=
12
12
  data.tar.gz: !binary |-
13
- OWY3MGE2YTdlN2RkODIyNmEyZjMwZTg3OTQ2NWRhZTBmZTU1M2JlMGI5NGM0
14
- ZGJmYTA5MzlkZTQxNDhjNDJkZThlODI1YzZkYWZiMjc2YjBiMmM1NThkNDUx
15
- N2I5NTFjMDFiMjJjYWI1NzdjNmQxNDNjMGFkYmZmMGM3MjQ0NzA=
13
+ NmUzODk2NWE3NWYwOGNiYTU4MGMyNmNhNTVhMWFmYTdlYzU1NTVkMzU5OGNl
14
+ NmY1MTkwNDNlMGY1NDNmNmQxMWRhODM0YWIzZjdiYmNhMmQwYjc5ZTQ5ZWM1
15
+ NjlhNTY2OWMwMTFlMzVhYjdlMzAzN2ZmZTg0ZWJkOGM1MjA1YTk=
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "Avatax_AddressService"
3
- s.version = "1.0.9"
3
+ s.version = "1.0.10"
4
4
  s.date = "2012-12-16"
5
5
  s.author = "Graham S Wilson"
6
6
  s.email = "support@Avalara.com"
@@ -10,10 +10,11 @@ Gem::Specification.new do |s|
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
12
  "lib/template_validate.erb","lib/template_ping.erb","lib/template_isauthorized.erb",
13
- "Avatax_AddressService.gemspec", "Avatax Ruby SDK Guide.docx", "LICENSE.txt"]
13
+ "samples/credentials.yml", "samples/Ping.rb","samples/Validate.rb",
14
+ "spec/addressservice_spec.rb","spec/isauthorized_spec.rb","spec/ping_spec.rb","spec/spec_helper.rb","spec/validate_spec.rb",
15
+ "Avatax_AddressService.gemspec","Avatax Ruby SDK Guide.docx","LICENSE.txt"]
14
16
  # s.add_dependency "nokogiri", ">= 1.4.0", "< 1.6"
15
17
  s.add_dependency "savon", ">= 2.3.0"
16
18
  s.required_ruby_version = '>=1.9.1'
17
19
  s.post_install_message = 'Thanks for installing the Avalara AddressService Ruby SDK. Refer to "Avatax Ruby SDK User Guide.docx" to get started.'
18
- end
19
-
20
+ end
data/samples/Ping.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'Avatax_AddressService'
2
+ require 'yaml'
3
+ #Note that the ping function exists in both the AddressSvc and TaxSvc classes - it works the same way in both.
4
+
5
+ #Create an instance of the service class
6
+ credentials = YAML::load(File.open('credentials.yml'))
7
+ svc = AvaTax::AddressService.new(:username => credentials['username'],
8
+ :password => credentials['password'],
9
+ :clientname => credentials['clientname'],
10
+ :use_production_url => credentials['production'])
11
+
12
+ #Call the service
13
+ result = svc.ping
14
+ #print result
15
+
16
+ #Display the result
17
+ puts "Ping ResultCode: "+result[:result_code]
18
+
19
+ #If we encountered an error
20
+ if result[:result_code] != "Success"
21
+ #Print the first error message returned
22
+ puts result[:details]
23
+ end
@@ -0,0 +1,37 @@
1
+ require 'Avatax_AddressService'
2
+ require 'yaml'
3
+
4
+ #Create an instance of the service class
5
+ credentials = YAML::load(File.open('credentials.yml'))
6
+ svc = AvaTax::AddressService.new(:username => credentials['username'],
7
+ :password => credentials['password'],
8
+ :clientname => credentials['clientname'],
9
+ :use_production_url => credentials['production'])
10
+
11
+ # Create the request
12
+ input = {
13
+ :line1 => "General Delivery", #Required
14
+ :line2 => "Suite 100", #Optional
15
+ :line3 => "Attn: Accounts Payable", #Optional
16
+ :city =>"Seattle", #Required, if PostalCode is not specified
17
+ :region=>"WA", #Required, if PostalCode is not specified
18
+ :postalcode =>"98101", #Required, if City and Region are not specified
19
+ :country => "US" #Optional
20
+ }
21
+ #Call the service
22
+ result = svc.validate(input)
23
+ #Display the result
24
+ #print result
25
+
26
+ #If we encountered an error
27
+ if result[:result_code] != "Success"
28
+ #puts the first error message returned
29
+ puts "Address Validation ResultCode: "+result[:result_code]
30
+ puts result[:details]
31
+ else
32
+ puts "Validated Address: "
33
+ result[:valid_addresses][:valid_address].each do |key, value|
34
+ puts key.to_s + ": " + value.to_s if not value.nil?
35
+ end
36
+
37
+ end
@@ -0,0 +1,5 @@
1
+ username: username
2
+ password: password
3
+ clientname: AvaTaxCalcSOAP Ruby Sample
4
+ production: false
5
+ companycode: APITrialCompany
@@ -0,0 +1,42 @@
1
+ require "spec_helper"
2
+
3
+ describe "AddressService" do
4
+ before :each do
5
+ credentials = YAML::load(File.open('credentials.yml'))
6
+ @creds = {:username => credentials['username'],
7
+ :password => credentials['password'],
8
+ :clientname => credentials['clientname'],
9
+ :use_production_url => credentials['production']}
10
+ end
11
+
12
+ describe "does not allow instantiation with" do
13
+ it "no values" do
14
+ lambda { AvaTax::AddressService.new }.should raise_exception
15
+ end
16
+ it "optional values only" do
17
+ lambda { AvaTax::AddressService.new(
18
+ :clientname => @creds[:clientname],
19
+ :adapter => "AvaTaxCalcRuby",
20
+ :machine => "MyComputer",
21
+ :use_production_account => @creds[:use_production_url] ) }.should raise_exception
22
+ end
23
+ end
24
+ describe "allows instantiation with" do
25
+ it "required values only" do
26
+ lambda { AvaTax::AddressService.new(
27
+ :username => @creds[:username],
28
+ :password => @creds[:password],
29
+ :clientname => @creds[:clientname]) }.should_not raise_exception
30
+ end
31
+ it "required and optional values" do
32
+ lambda { AvaTax::AddressService.new(
33
+ :username => @creds[:username],
34
+ :password => @creds[:password],
35
+ :clientname => @creds[:clientname],
36
+ :adapter => "AvaTaxCalcRuby",
37
+ :machine => "MyComputer",
38
+ :use_production_account => false ) }.should_not raise_exception
39
+ end
40
+ end
41
+
42
+ end
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ describe "IsAuthorized" do
4
+ before :each do
5
+ credentials = YAML::load(File.open('credentials.yml'))
6
+ @creds = {:username => credentials['username'],
7
+ :password => credentials['password'],
8
+ :clientname => credentials['clientname'],
9
+ :use_production_url => credentials['production']}
10
+ end
11
+
12
+ describe "returns a meaningful" do
13
+ it "error when URL is missing" do
14
+ @creds[:use_production_url] = nil
15
+ @service = AvaTax::AddressService.new(@creds)
16
+ @service.isauthorized[:result_code].should eql "Success"
17
+ end
18
+ it "success when URL is specified" do
19
+ @creds[:use_production_url] = false
20
+ @service = AvaTax::AddressService.new(@creds)
21
+ @service.isauthorized[:result_code].should eql "Success"
22
+ end
23
+ it "error when username is missing" do
24
+ @creds[:username] = nil
25
+ @service = AvaTax::AddressService.new(@creds)
26
+ @service.isauthorized[:result_code].should eql "Error"
27
+ end
28
+ it "error when password is omitted" do
29
+ @creds[:password] = nil
30
+ @service = AvaTax::AddressService.new(@creds)
31
+ @service.isauthorized[:result_code].should eql "Error"
32
+ end
33
+ it "success when clientname is omitted" do
34
+ @creds[:clientname] = nil
35
+ @service = AvaTax::AddressService.new(@creds)
36
+ @service.isauthorized[:result_code].should eql "Success"
37
+ end
38
+ end
39
+
40
+ describe "has consistent formatting for" do
41
+ it "internal logic errors" do
42
+ @service = AvaTax::AddressService.new(@creds)
43
+ lambda { @service.isauthorized("param1","param2") }.should raise_exception
44
+ end
45
+ it "server-side errors" do
46
+ @creds[:password] = nil
47
+ @service = AvaTax::AddressService.new(@creds)
48
+ @result = @service.isauthorized
49
+ @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
50
+ end
51
+ it "successful results" do
52
+ @service = AvaTax::AddressService.new(@creds)
53
+ @result = @service.isauthorized
54
+ @result[:result_code].should eql "Success" and @result[:expires].should_not be_nil
55
+ end
56
+ end
57
+ describe "requests with" do
58
+ it "missing required parameters fail" do
59
+ true #there are no required parameters for isauthorized
60
+ end
61
+ it "invalid parameters fail" do
62
+ @service = AvaTax::AddressService.new(@creds)
63
+ lambda { @service.isauthorized("param1","param2") }.should raise_exception
64
+ end
65
+ it "missing optional parameters succeed" do
66
+ @service = AvaTax::AddressService.new(@creds)
67
+ @service.isauthorized[:result_code].should eql "Success"
68
+ end
69
+ it "all parameters succeed" do
70
+ @service = AvaTax::AddressService.new(@creds)
71
+ @service.isauthorized("Message")[:result_code].should eql "Success"
72
+ end
73
+ end
74
+
75
+ end
data/spec/ping_spec.rb ADDED
@@ -0,0 +1,75 @@
1
+ require "spec_helper"
2
+
3
+ describe "Ping" do
4
+ before :each do
5
+ credentials = YAML::load(File.open('credentials.yml'))
6
+ @creds = {:username => credentials['username'],
7
+ :password => credentials['password'],
8
+ :clientname => credentials['clientname'],
9
+ :use_production_url => credentials['production']}
10
+ end
11
+
12
+ describe "returns a meaningful" do
13
+ it "error when URL is missing" do
14
+ @creds[:use_production_url] = nil
15
+ @service = AvaTax::AddressService.new(@creds)
16
+ @service.ping[:result_code].should eql "Success"
17
+ end
18
+ it "success when URL is specified" do
19
+ @creds[:use_production_url] = false
20
+ @service = AvaTax::AddressService.new(@creds)
21
+ @service.ping[:result_code].should eql "Success"
22
+ end
23
+ it "error when username is missing" do
24
+ @creds[:username] = nil
25
+ @service = AvaTax::AddressService.new(@creds)
26
+ @service.ping[:result_code].should eql "Error"
27
+ end
28
+ it "error when password is omitted" do
29
+ @creds[:password] = nil
30
+ @service = AvaTax::AddressService.new(@creds)
31
+ @service.ping[:result_code].should eql "Error"
32
+ end
33
+ it "success when clientname is omitted" do
34
+ @creds[:clientname] = nil
35
+ @service = AvaTax::AddressService.new(@creds)
36
+ @service.ping[:result_code].should eql "Success"
37
+ end
38
+ end
39
+
40
+ describe "has consistent formatting for" do
41
+ it "internal logic errors" do
42
+ @service = AvaTax::AddressService.new(@creds)
43
+ lambda { @service.ping("param1","param2") }.should raise_exception
44
+ end
45
+ it "server-side errors" do
46
+ @creds[:password] = nil
47
+ @service = AvaTax::AddressService.new(@creds)
48
+ @result = @service.ping
49
+ @result[:result_code].should eql "Error" and @result[:details].should eql "The user or account could not be authenticated."
50
+ end
51
+ it "successful results" do
52
+ @service = AvaTax::AddressService.new(@creds)
53
+ @result = @service.ping
54
+ @result[:result_code].should eql "Success" and @result[:version].should_not be_nil
55
+ end
56
+ end
57
+ describe "requests with" do
58
+ it "missing required parameters fail" do
59
+ true #there are no required parameters for ping
60
+ end
61
+ it "invalid parameters fail" do
62
+ @service = AvaTax::AddressService.new(@creds)
63
+ lambda { @service.ping("param1","param2") }.should raise_exception
64
+ end
65
+ it "missing optional parameters succeed" do
66
+ @service = AvaTax::AddressService.new(@creds)
67
+ @service.ping[:result_code].should eql "Success"
68
+ end
69
+ it "all parameters succeed" do
70
+ @service = AvaTax::AddressService.new(@creds)
71
+ @service.ping("Message")[:result_code].should eql "Success"
72
+ end
73
+ end
74
+
75
+ end
@@ -0,0 +1,17 @@
1
+ # spec/awesome_gem/awesome.rb
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
3
+ $: << File.join(APP_ROOT, 'lib') # so rspec knows where your file could be
4
+ require 'avatax_addressservice.rb' # this loads the class you want to test
5
+ require 'yaml'
6
+
7
+
8
+ RSpec.configure do |config|
9
+ # Use color in STDOUT
10
+ config.color_enabled = true
11
+
12
+ # Use color not only in STDOUT but also in pagers and files
13
+ config.tty = true
14
+
15
+ # Use the specified formatter
16
+ config.formatter = :documentation # :progress, :html, :textmate
17
+ end
@@ -0,0 +1,83 @@
1
+ require "spec_helper"
2
+
3
+ describe "Validate" do
4
+ before :each do
5
+ @address_req = {:line1 => "100 Ravine Lane NE", :postalcode => "98110"}
6
+ @address_opt = {
7
+ :addresscode => "02",
8
+ :line2 => "Attn: Avalara",
9
+ :line3 => "Suite 200",
10
+ :city => "Bainbridge Island",
11
+ :region => "WA",
12
+ :country => "US",
13
+ :taxregionid => "234",
14
+ :latitude => "47.624935",
15
+ :longitude => "-122.515068",
16
+ :textcase => "Upper",
17
+ :coordinates => "true",
18
+ :taxability => "true"}
19
+ credentials = YAML::load(File.open('credentials.yml'))
20
+ @creds = {:username => credentials['username'],
21
+ :password => credentials['password'],
22
+ :clientname => credentials['clientname'],
23
+ :use_production_url => credentials['production']}
24
+ @svc = AvaTax::AddressService.new(@creds)
25
+ end
26
+
27
+ describe "returns a meaningful" do
28
+ it "error when URL is missing" do
29
+ @creds[:use_production_url] = nil
30
+ @service = AvaTax::AddressService.new(@creds)
31
+ @service.validate(@address_req)[:result_code].should eql "Success"
32
+ end
33
+ it "success when URL is specified" do
34
+ @creds[:use_production_url] = false
35
+ @service = AvaTax::AddressService.new(@creds)
36
+ @service.validate(@address_req)[:result_code].should eql "Success"
37
+ end
38
+ it "error when username is missing" do
39
+ @creds[:username] = nil
40
+ @service = AvaTax::AddressService.new(@creds)
41
+ @service.validate(@address_req)[:result_code].should eql "Error"
42
+ end
43
+ it "error when password is omitted" do
44
+ @creds[:password] = nil
45
+ @service = AvaTax::AddressService.new(@creds)
46
+ @service.validate(@address_req)[:result_code].should eql "Error"
47
+ end
48
+ it "success when clientname is omitted" do
49
+ @creds[:clientname] = nil
50
+ @service = AvaTax::AddressService.new(@creds)
51
+ @service.validate(@address_req)[:result_code].should eql "Success"
52
+ end
53
+ end
54
+
55
+ describe "has consistent formatting for" do
56
+ it "internal logic errors" do
57
+ lambda { @svc.validate(@address_req, @address_req) }.should raise_exception
58
+ end
59
+ it "server-side errors" do
60
+ @creds[:password] = nil
61
+ @service = AvaTax::AddressService.new(@creds)
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."
64
+ end
65
+ it "successful results" do
66
+ @result = @svc.validate(@address_req)
67
+ @result[:result_code].should eql "Success" and @result[:valid_addresses].should_not be_nil
68
+ end
69
+ end
70
+ describe "requests with" do
71
+ it "missing required parameters fail" do
72
+ @address_req[:line1] = nil
73
+ @svc.validate(@address_req)[:result_code].should eql "Error"
74
+ end
75
+ it "missing optional parameters succeed" do
76
+ @svc.validate(@address_req)[:result_code].should eql "Success"
77
+ end
78
+ it "all parameters succeed" do
79
+ @address_full = @address_req.merge(@address_opt)
80
+ @svc.validate(@address_full)[:result_code].should eql "Success"
81
+ end
82
+ end
83
+ end
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.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham S Wilson
@@ -37,6 +37,14 @@ files:
37
37
  - lib/template_validate.erb
38
38
  - lib/template_ping.erb
39
39
  - lib/template_isauthorized.erb
40
+ - samples/credentials.yml
41
+ - samples/Ping.rb
42
+ - samples/Validate.rb
43
+ - spec/addressservice_spec.rb
44
+ - spec/isauthorized_spec.rb
45
+ - spec/ping_spec.rb
46
+ - spec/spec_helper.rb
47
+ - spec/validate_spec.rb
40
48
  - Avatax_AddressService.gemspec
41
49
  - Avatax Ruby SDK Guide.docx
42
50
  - LICENSE.txt