avatax 14.4.4 → 17.5.0

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.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +54 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +5 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +201 -191
  8. data/README.md +63 -61
  9. data/Rakefile +9 -0
  10. data/avatax.gemspec +39 -0
  11. data/example/avatax.rb +14 -0
  12. data/example/credentials.example.yaml +5 -0
  13. data/lib/avatax.rb +19 -13
  14. data/lib/avatax/api.rb +27 -0
  15. data/lib/avatax/client.rb +32 -0
  16. data/lib/avatax/client/accounts.rb +110 -0
  17. data/lib/avatax/client/addresses.rb +52 -0
  18. data/lib/avatax/client/batches.rb +117 -0
  19. data/lib/avatax/client/companies.rb +218 -0
  20. data/lib/avatax/client/contacts.rb +115 -0
  21. data/lib/avatax/client/definitions.rb +569 -0
  22. data/lib/avatax/client/filingcalendars.rb +313 -0
  23. data/lib/avatax/client/filings.rb +417 -0
  24. data/lib/avatax/client/free.rb +104 -0
  25. data/lib/avatax/client/fundingrequests.rb +53 -0
  26. data/lib/avatax/client/items.rb +111 -0
  27. data/lib/avatax/client/jurisdictionoverrides.rb +125 -0
  28. data/lib/avatax/client/locations.rb +158 -0
  29. data/lib/avatax/client/nexus.rb +157 -0
  30. data/lib/avatax/client/notices.rb +297 -0
  31. data/lib/avatax/client/onboarding.rb +23 -0
  32. data/lib/avatax/client/pointofsale.rb +24 -0
  33. data/lib/avatax/client/registrar.rb +216 -0
  34. data/lib/avatax/client/settings.rb +137 -0
  35. data/lib/avatax/client/subscriptions.rb +66 -0
  36. data/lib/avatax/client/taxcodes.rb +127 -0
  37. data/lib/avatax/client/taxrules.rb +127 -0
  38. data/lib/avatax/client/transactions.rb +473 -0
  39. data/lib/avatax/client/upcs.rb +112 -0
  40. data/lib/avatax/client/users.rb +112 -0
  41. data/lib/avatax/client/utilities.rb +52 -0
  42. data/lib/avatax/configuration.rb +53 -18
  43. data/lib/avatax/connection.rb +28 -0
  44. data/lib/avatax/request.rb +38 -0
  45. data/lib/avatax/version.rb +3 -0
  46. data/spec/avatax/client/accounts_spec.rb +26 -0
  47. data/spec/avatax_spec.rb +59 -0
  48. data/spec/fixtures/accounts.json +16 -0
  49. data/spec/spec_helper.rb +47 -0
  50. metadata +143 -30
  51. data/lib/avatax/address_service.rb +0 -31
  52. data/lib/avatax/tax_service.rb +0 -61
@@ -0,0 +1,59 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ describe AvaTax do
4
+ puts "Got env", ENV["SANDBOX_USERNAME"]
5
+
6
+ after do
7
+ AvaTax.reset
8
+ end
9
+
10
+ context "when delegating to a client" do
11
+
12
+ before do
13
+ stub_get("/api/v2/accounts").
14
+ to_return(:body => fixture("accounts.json"), :headers => {:content_type => "application/json; charset=utf-8"})
15
+ end
16
+
17
+ it "should get the correct resource" do
18
+ AvaTax.query_accounts()
19
+ expect(a_get("/api/v2/accounts")).to have_been_made
20
+ end
21
+
22
+ it "should return the same results as a client" do
23
+ expect(AvaTax.query_accounts()).to eq AvaTax::Client.new().query_accounts()
24
+ end
25
+
26
+ end
27
+
28
+ describe ".client" do
29
+ it "should be a AvaTax::Client" do
30
+ expect(AvaTax.client).to be_a AvaTax::Client
31
+ end
32
+ end
33
+
34
+ describe ".endpoint" do
35
+ it "should return the default endpoint" do
36
+ expect(AvaTax.endpoint).to eq AvaTax::Configuration::DEFAULT_ENDPOINT
37
+ end
38
+ end
39
+
40
+ describe ".endpoint=" do
41
+ it "should set the endpoint" do
42
+ AvaTax.endpoint = 'https://sandbox-rest.avatax.com'
43
+ expect(AvaTax.endpoint).to eq 'https://sandbox-rest.avatax.com'
44
+ end
45
+ end
46
+
47
+ describe ".configure" do
48
+
49
+ AvaTax::Configuration::VALID_OPTIONS_KEYS.each do |key|
50
+
51
+ it "should set the #{key}" do
52
+ AvaTax.configure do |config|
53
+ config.send("#{key}=", key)
54
+ expect(AvaTax.send(key)).to eq key
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,16 @@
1
+ {
2
+ "@recordsetCount": 1,
3
+ "value": [
4
+ {
5
+ "id": 200000251,
6
+ "name": "Avalara",
7
+ "effectiveDate": "2015-11-05T00:00:00",
8
+ "endDate": "2999-02-05T00:00:00",
9
+ "accountStatusId": "Active",
10
+ "createdDate": "2015-11-05T22:11:17.593",
11
+ "createdUserId": 46103,
12
+ "modifiedDate": "2017-01-10T18:55:36.193",
13
+ "modifiedUserId": 54057
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,47 @@
1
+ require File.expand_path('../../lib/avatax', __FILE__)
2
+ require 'rspec'
3
+ require 'webmock/rspec'
4
+
5
+ RSpec.configure do |config|
6
+ config.include WebMock::API
7
+ end
8
+
9
+ def a_delete(path)
10
+ a_request(:delete, AvaTax.endpoint + path)
11
+ end
12
+
13
+ def a_get(path)
14
+ a_request(:get, AvaTax.endpoint + path)
15
+ end
16
+
17
+ def a_post(path)
18
+ a_request(:post, AvaTax.endpoint + path)
19
+ end
20
+
21
+ def a_put(path)
22
+ a_request(:put, AvaTax.endpoint + path)
23
+ end
24
+
25
+ def stub_delete(path)
26
+ stub_request(:delete, AvaTax.endpoint + path)
27
+ end
28
+
29
+ def stub_get(path)
30
+ stub_request(:get, AvaTax.endpoint + path)
31
+ end
32
+
33
+ def stub_post(path)
34
+ stub_request(:post, AvaTax.endpoint + path)
35
+ end
36
+
37
+ def stub_put(path)
38
+ stub_request(:put, AvaTax.endpoint + path)
39
+ end
40
+
41
+ def fixture_path
42
+ File.expand_path("../fixtures", __FILE__)
43
+ end
44
+
45
+ def fixture(file)
46
+ File.new(fixture_path + '/' + file)
47
+ end
metadata CHANGED
@@ -1,76 +1,185 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avatax
3
3
  version: !ruby/object:Gem::Version
4
- version: 14.4.4
4
+ version: 17.5.0
5
5
  platform: ruby
6
6
  authors:
7
- - Anya Stettler
8
- - Jeff Weiss
7
+ - Marcus Vorwaller
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-11-07 00:00:00.000000000 Z
11
+ date: 2017-06-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: json
14
+ name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
17
  - - "~>"
19
18
  - !ruby/object:Gem::Version
20
- version: '1.8'
21
- type: :runtime
19
+ version: 12.0.0
20
+ type: :development
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
24
  - - "~>"
26
25
  - !ruby/object:Gem::Version
27
- version: '1.8'
26
+ version: 12.0.0
28
27
  - !ruby/object:Gem::Dependency
29
- name: rest-client
28
+ name: rspec
30
29
  requirement: !ruby/object:Gem::Requirement
31
30
  requirements:
32
31
  - - "~>"
33
32
  - !ruby/object:Gem::Version
34
- version: '1.7'
35
- type: :runtime
33
+ version: 3.5.0
34
+ type: :development
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - "~>"
40
39
  - !ruby/object:Gem::Version
41
- version: '1.7'
40
+ version: 3.5.0
42
41
  - !ruby/object:Gem::Dependency
43
- name: addressable
42
+ name: webmock
44
43
  requirement: !ruby/object:Gem::Requirement
45
44
  requirements:
46
- - - "~>"
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 2.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: faraday
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
47
60
  - !ruby/object:Gem::Version
48
- version: '2.3'
61
+ version: '0.10'
49
62
  type: :runtime
50
63
  prerelease: false
51
64
  version_requirements: !ruby/object:Gem::Requirement
52
65
  requirements:
53
- - - "~>"
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0.10'
69
+ - !ruby/object:Gem::Dependency
70
+ name: faraday_middleware
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0.10'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0.10'
83
+ - !ruby/object:Gem::Dependency
84
+ name: multi_json
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
54
95
  - !ruby/object:Gem::Version
55
- version: '2.3'
56
- description: Provides a straightforward way to access and communicate with the all
57
- methods exposed by the Avalara AvaTax REST API.
58
- email: anya.stettler@avalara.com
96
+ version: 1.0.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: hashie
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ description: A Ruby wrapper for the AvaTax REST and Search APIs
112
+ email:
113
+ - marcus.vorwaller@avalara.com
59
114
  executables: []
60
115
  extensions: []
61
116
  extra_rdoc_files: []
62
117
  files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - ".yardopts"
122
+ - Gemfile
63
123
  - LICENSE
64
124
  - README.md
125
+ - Rakefile
126
+ - avatax.gemspec
127
+ - example/avatax.rb
128
+ - example/credentials.example.yaml
65
129
  - lib/avatax.rb
66
- - lib/avatax/address_service.rb
130
+ - lib/avatax/api.rb
131
+ - lib/avatax/client.rb
132
+ - lib/avatax/client/accounts.rb
133
+ - lib/avatax/client/addresses.rb
134
+ - lib/avatax/client/batches.rb
135
+ - lib/avatax/client/companies.rb
136
+ - lib/avatax/client/contacts.rb
137
+ - lib/avatax/client/definitions.rb
138
+ - lib/avatax/client/filingcalendars.rb
139
+ - lib/avatax/client/filings.rb
140
+ - lib/avatax/client/free.rb
141
+ - lib/avatax/client/fundingrequests.rb
142
+ - lib/avatax/client/items.rb
143
+ - lib/avatax/client/jurisdictionoverrides.rb
144
+ - lib/avatax/client/locations.rb
145
+ - lib/avatax/client/nexus.rb
146
+ - lib/avatax/client/notices.rb
147
+ - lib/avatax/client/onboarding.rb
148
+ - lib/avatax/client/pointofsale.rb
149
+ - lib/avatax/client/registrar.rb
150
+ - lib/avatax/client/settings.rb
151
+ - lib/avatax/client/subscriptions.rb
152
+ - lib/avatax/client/taxcodes.rb
153
+ - lib/avatax/client/taxrules.rb
154
+ - lib/avatax/client/transactions.rb
155
+ - lib/avatax/client/upcs.rb
156
+ - lib/avatax/client/users.rb
157
+ - lib/avatax/client/utilities.rb
67
158
  - lib/avatax/configuration.rb
68
- - lib/avatax/tax_service.rb
69
- homepage: http://www.avalara.com/
70
- licenses:
71
- - Apache-2.0
159
+ - lib/avatax/connection.rb
160
+ - lib/avatax/request.rb
161
+ - lib/avatax/version.rb
162
+ - spec/avatax/client/accounts_spec.rb
163
+ - spec/avatax_spec.rb
164
+ - spec/fixtures/accounts.json
165
+ - spec/spec_helper.rb
166
+ homepage: https://github.com/avadev/AvaTax-REST-V2-Ruby-SDK
167
+ licenses: []
72
168
  metadata: {}
73
- post_install_message:
169
+ post_install_message: |
170
+ ********************************************************************************
171
+
172
+ AvaTax REST API
173
+ ------------------------------
174
+ Our developer site documents the AvaTax REST API.
175
+ (http://developer.avatax.com).
176
+ Blog
177
+ ----------------------------
178
+ The Developer Blog is a great place to learn more about the API and AvaTax integrations
179
+ Subscribe to the RSS feed be notified of new posts:
180
+ (http://developer.avatax.com/blog).
181
+
182
+ ********************************************************************************
74
183
  rdoc_options: []
75
184
  require_paths:
76
185
  - lib
@@ -83,11 +192,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
192
  requirements:
84
193
  - - ">="
85
194
  - !ruby/object:Gem::Version
86
- version: '0'
195
+ version: 2.0.0
87
196
  requirements: []
88
197
  rubyforge_project:
89
- rubygems_version: 2.4.1
198
+ rubygems_version: 2.6.11
90
199
  signing_key:
91
200
  specification_version: 4
92
- summary: Library for accessing Avalara's AvaTax and Address Validation services
93
- test_files: []
201
+ summary: Ruby wrapper for the AvaTax API
202
+ test_files:
203
+ - spec/avatax/client/accounts_spec.rb
204
+ - spec/avatax_spec.rb
205
+ - spec/fixtures/accounts.json
206
+ - spec/spec_helper.rb
@@ -1,31 +0,0 @@
1
- require 'json'
2
- require 'net/http'
3
- require 'addressable/uri'
4
- require 'base64'
5
- require_relative 'configuration'
6
-
7
- class AvaTax::AddressService
8
- @@service_path = '/1.0/address/'
9
- attr_accessor :account_number, :license_key, :service_url
10
-
11
- def initialize()
12
- @account_number = AvaTax::Configuration.instance.account_number
13
- @license_key = AvaTax::Configuration.instance.license_key
14
- @service_url = AvaTax::Configuration.instance.service_url
15
- end
16
-
17
- def validate(address)
18
- return address if address.nil?
19
- encodedquery = Addressable::URI.new
20
- encodedquery.query_values = address
21
- uri = URI(@service_url + @@service_path + "validate?"+ encodedquery.query)
22
- http = Net::HTTP.new(uri.host, uri.port)
23
- http.use_ssl = true
24
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
25
-
26
- cred = 'Basic '+ Base64.encode64(@account_number + ":"+ @license_key)
27
- res = http.get(uri.request_uri, 'Authorization' => cred)
28
- JSON.parse(res.body)
29
- end
30
-
31
- end
@@ -1,61 +0,0 @@
1
- require 'json'
2
- require 'net/http'
3
- require 'addressable/uri'
4
- require 'base64'
5
- require 'rest-client'
6
- require_relative 'configuration'
7
-
8
- class AvaTax::TaxService
9
- @@service_path = "/1.0/tax/"
10
- attr_accessor :account_number, :license_key, :service_url
11
-
12
- def initialize()
13
- #puts AvaTax::Configuration.instance.inspect
14
- @account_number = AvaTax::Configuration.instance.account_number
15
- @license_key = AvaTax::Configuration.instance.license_key
16
- @service_url = AvaTax::Configuration.instance.service_url
17
- end
18
-
19
- def get(request_hash)
20
- uri = @service_url + @@service_path + "get"
21
- cred = 'Basic '+ Base64.encode64(@account_number + ":"+ @license_key)
22
- #puts JSON.generate(request_hash)
23
- res = RestClient.post(uri, JSON.generate(request_hash), :authorization => cred, :content_type => 'application/json'){|response, request, result| response}
24
- JSON.parse(res.body)
25
- end
26
-
27
-
28
- def cancel(request_hash)
29
- uri = @service_url + @@service_path + "cancel"
30
- cred = 'Basic '+ Base64.encode64(@account_number + ":"+ @license_key)
31
- res = RestClient.post uri, JSON.generate(request_hash), :authorization => cred, :content_type => 'application/json'
32
- JSON.parse(res.body)["CancelTaxResult"]
33
- #You may notice that this is slightly different from CalcTax, etc. The CancelTax result is nested in this result object - this makes it consumable in a way that is consistant with the other response formats.
34
- end
35
-
36
- def estimate(coordinates, sale_amount)
37
- # coordinates should be a hash with latitude and longitude
38
- # sale_amount should be a decimal
39
- return nil if coordinates.nil?
40
- sale_amount = 0 if sale_amount.nil?
41
- uri = URI(@service_url + @@service_path +
42
- coordinates[:latitude].to_s + "," + coordinates[:longitude].to_s +
43
- "/get?saleamount=" + sale_amount.to_s )
44
- http = Net::HTTP.new(uri.host, uri.port)
45
- http.use_ssl = true
46
- http.verify_mode = OpenSSL::SSL::VERIFY_PEER
47
- cred = 'Basic '+ Base64.encode64(@account_number + ":"+ @license_key)
48
- res = http.get(uri.request_uri, 'Authorization' => cred, 'Content-Type' => 'application/json')
49
- JSON.parse(res.body)
50
- end
51
-
52
- def ping
53
- #There is no actual ping in the REST API, so this is a mockup that calls EstimateTax with
54
- #hardcoded values.
55
- self.estimate(
56
- { :latitude => "47.627935",
57
- :longitude => "-122.51702"},
58
- 0 )
59
- end
60
-
61
- end