tax_cloud 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/test.yml +30 -0
  3. data/.rubocop.yml +9 -25
  4. data/.rubocop_todo.yml +47 -0
  5. data/CHANGELOG.md +85 -0
  6. data/CONTRIBUTORS.txt +3 -0
  7. data/Gemfile +15 -5
  8. data/LICENSE.md +21 -0
  9. data/README.md +200 -0
  10. data/Rakefile +5 -19
  11. data/lib/config/locales/en.yml +2 -2
  12. data/lib/hash.rb +3 -4
  13. data/lib/tasks/tax_cloud.rake +4 -4
  14. data/lib/tasks/tax_code_groups.rake +11 -11
  15. data/lib/tasks/tax_codes.rake +12 -12
  16. data/lib/tax_cloud/address.rb +10 -5
  17. data/lib/tax_cloud/cart_item.rb +2 -0
  18. data/lib/tax_cloud/client.rb +13 -3
  19. data/lib/tax_cloud/configuration.rb +13 -2
  20. data/lib/tax_cloud/errors/api_error.rb +3 -3
  21. data/lib/tax_cloud/errors/missing_config_error.rb +2 -1
  22. data/lib/tax_cloud/errors/missing_config_option_error.rb +2 -1
  23. data/lib/tax_cloud/errors/soap_error.rb +6 -6
  24. data/lib/tax_cloud/errors/tax_cloud_error.rb +5 -4
  25. data/lib/tax_cloud/errors/unexpected_soap_response_error.rb +3 -3
  26. data/lib/tax_cloud/errors.rb +2 -0
  27. data/lib/tax_cloud/record.rb +2 -0
  28. data/lib/tax_cloud/responses/authorized.rb +3 -1
  29. data/lib/tax_cloud/responses/authorized_with_capture.rb +3 -1
  30. data/lib/tax_cloud/responses/base.rb +5 -4
  31. data/lib/tax_cloud/responses/captured.rb +3 -1
  32. data/lib/tax_cloud/responses/cart_item.rb +6 -2
  33. data/lib/tax_cloud/responses/generic.rb +2 -0
  34. data/lib/tax_cloud/responses/lookup.rb +10 -8
  35. data/lib/tax_cloud/responses/ping.rb +3 -1
  36. data/lib/tax_cloud/responses/returned.rb +3 -1
  37. data/lib/tax_cloud/responses/tax_code_groups.rb +3 -1
  38. data/lib/tax_cloud/responses/tax_codes.rb +3 -1
  39. data/lib/tax_cloud/responses/tax_codes_by_group.rb +3 -1
  40. data/lib/tax_cloud/responses/verify_address.rb +3 -1
  41. data/lib/tax_cloud/responses.rb +2 -0
  42. data/lib/tax_cloud/tax_code.rb +2 -0
  43. data/lib/tax_cloud/tax_code_constants.rb +262 -260
  44. data/lib/tax_cloud/tax_code_group.rb +3 -1
  45. data/lib/tax_cloud/tax_code_group_constants.rb +2 -0
  46. data/lib/tax_cloud/tax_code_groups.rb +3 -1
  47. data/lib/tax_cloud/tax_codes.rb +3 -1
  48. data/lib/tax_cloud/transaction.rb +2 -0
  49. data/lib/tax_cloud/version.rb +3 -1
  50. data/lib/tax_cloud.rb +8 -3
  51. data/tax_cloud.gemspec +17 -18
  52. data/test/cassettes/authorized.yml +6 -6
  53. data/test/cassettes/authorized_with_capture.yml +6 -6
  54. data/test/cassettes/authorized_with_localized_time.yml +6 -6
  55. data/test/cassettes/captured.yml +7 -7
  56. data/test/cassettes/get_tic_groups.yml +5 -5
  57. data/test/cassettes/get_tics.yml +5 -5
  58. data/test/cassettes/get_tics_by_group.yml +5 -5
  59. data/test/cassettes/invalid_soap_call.yml +5 -5
  60. data/test/cassettes/lookup.yml +5 -5
  61. data/test/cassettes/lookup_ny.yml +5 -5
  62. data/test/cassettes/ping.yml +5 -5
  63. data/test/cassettes/ping_with_invalid_credentials.yml +5 -5
  64. data/test/cassettes/ping_with_invalid_response.yml +5 -5
  65. data/test/cassettes/returned.yml +7 -7
  66. data/test/cassettes/verify_bad_address.yml +5 -5
  67. data/test/cassettes/verify_good_address.yml +5 -5
  68. data/test/helper.rb +3 -1
  69. data/test/test_address.rb +7 -5
  70. data/test/test_cart_item.rb +3 -1
  71. data/test/test_client.rb +4 -2
  72. data/test/test_configuration_optional_keys.rb +44 -0
  73. data/test/{test_configuration.rb → test_configuration_required_keys.rb} +6 -4
  74. data/test/test_lookup_response.rb +22 -0
  75. data/test/test_setup.rb +3 -1
  76. data/test/test_soap.rb +3 -1
  77. data/test/test_tax_code_groups.rb +4 -2
  78. data/test/test_tax_codes.rb +3 -1
  79. data/test/test_transaction.rb +3 -1
  80. data/test/test_transaction_ny.rb +3 -1
  81. data/test/vcr_setup.rb +2 -0
  82. metadata +37 -91
  83. data/.travis.yml +0 -6
  84. data/CHANGELOG.rdoc +0 -42
  85. data/LICENSE.rdoc +0 -22
  86. data/README.rdoc +0 -140
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dce34f03969027431c16d3504d5f02106ae8c086
4
- data.tar.gz: c55d7e4fa58df6cc206994e42ad2f0bfff8ead2b
2
+ SHA256:
3
+ metadata.gz: 55a0579c5212968283b84a2e6a87921e8d741d182e4f23337d480435c26dbec6
4
+ data.tar.gz: 7cb858801bc88041e2b402962c5dc05d91afb6b52dc3fe793c4a943014b7d1bc
5
5
  SHA512:
6
- metadata.gz: 4c0b46885a58ebf4ba0d807d32e7b342d57b5057824d024cc60ab699e32ec5ff9ea2f815ad466362d91e468f962c1bb9b198052052adfed99b74829d4308efc7
7
- data.tar.gz: 4b909e99313bfcb962d44d124cdaf1b8d2d4c27d1d067549ad00f823d474fbd1c6fe0ffc5912f3fc38aeb7cd6da9677cf89637844c7870b9bdd709642bfb1521
6
+ metadata.gz: efc17316081884f02aebf3d1064e81df78515e5b8ee9355c224d8be53ef7529833648295c692ab332d35018092c940b2c21d2356450fa67761db7cd563b472ca
7
+ data.tar.gz: b256cb07f74161ad04c869c258e75549fbed0920c2ce3a030e60a126518df9d32111df50afaba455b69682a31fc64f8cf30960b0c9e6c660da64f4b3c72fc994
@@ -0,0 +1,30 @@
1
+ # Reference https://github.com/actions/starter-workflows/blob/main/ci/ruby.yml
2
+ name: test
3
+ on: [push, pull_request]
4
+ jobs:
5
+ lint:
6
+ name: RuboCop
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v3
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7
14
+ bundler-cache: true
15
+ - name: Run RuboCop
16
+ run: bundle exec rubocop
17
+ test:
18
+ runs-on: ubuntu-latest
19
+ strategy:
20
+ matrix:
21
+ ruby-version: ['2.6', '2.7']
22
+ name: test (${{ matrix.ruby-version }})
23
+ steps:
24
+ - uses: actions/checkout@v3
25
+ - uses: ruby/setup-ruby@v1
26
+ with:
27
+ ruby-version: ${{ matrix.ruby-version }}
28
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
29
+ - run: bundle exec rake test
30
+
data/.rubocop.yml CHANGED
@@ -1,29 +1,13 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
- Excludes:
4
+ TargetRubyVersion: 2.6
5
+ NewCops: enable
6
+ Exclude:
3
7
  - vendor/**
8
+ - vendor/bundle/**/*
4
9
  - bin/**
5
10
 
6
- LineLength:
7
- Enabled: false
8
-
9
- MethodLength:
10
- Enabled: false
11
-
12
- ClassLength:
13
- Enabled: false
14
-
15
- Documentation:
16
- # don't require classes to be documented
17
- Enabled: false
18
-
19
- NumericLiterals:
20
- # don't separate numeric literals with _
21
- Enabled: false
22
-
23
- RaiseArgs:
24
- # don't need to provide an exception class and message, SoapError takes care of that
25
- Enabled: false
26
-
27
- Encoding:
28
- # missing UTF-8 comment
29
- Enabled: false
11
+ Style/NumericLiteralPrefix:
12
+ Enabled: true
13
+ EnforcedOctalStyle: zero_only
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,47 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-10-14 20:47:01 UTC using RuboCop version 0.93.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ Lint/MissingSuper:
11
+ Exclude:
12
+ - 'test/test_lookup_response.rb'
13
+
14
+ # Offense count: 3
15
+ # Configuration parameters: IgnoredMethods.
16
+ Metrics/AbcSize:
17
+ Max: 23
18
+
19
+ # Offense count: 5
20
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
21
+ # ExcludedMethods: refine
22
+ Metrics/BlockLength:
23
+ Max: 39
24
+
25
+ # Offense count: 1
26
+ # Configuration parameters: CountComments, CountAsOne.
27
+ Metrics/ClassLength:
28
+ Max: 261
29
+
30
+ # Offense count: 2
31
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
32
+ Metrics/MethodLength:
33
+ Max: 14
34
+
35
+ # Offense count: 1
36
+ Style/Documentation:
37
+ Exclude:
38
+ - 'spec/**/*'
39
+ - 'test/**/*'
40
+ - 'lib/tax_cloud/tax_codes.rb'
41
+
42
+ # Offense count: 61
43
+ # Cop supports --auto-correct.
44
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
45
+ # URISchemes: http, https
46
+ Layout/LineLength:
47
+ Max: 235
data/CHANGELOG.md ADDED
@@ -0,0 +1,85 @@
1
+ ### 0.5.0 (7/21/2023)
2
+
3
+ * Update README, CHANGELOG, and LICENSE from RDoc to Markdown -
4
+ @brchristian.
5
+ * Migrate from Travis CI to GitHub Actions -
6
+ @rchekaluk.
7
+ * Update WSDL endpoint URL as recommended by TaxCloud to
8
+ https://api.taxcloud.com/1.0/?wsdl - @mrmarcondes.
9
+
10
+
11
+ ### 0.4.0 (12/7/2020)
12
+
13
+ * Add `open_timeout` and `read_timeout` options into configuration -
14
+ @ka8725.
15
+ * Switch to using BigDecimal for `tax_amount` to avoid floating point
16
+ arithmetic errors - @paulhenrich.
17
+ * Require ruby 2.6.0+
18
+ * Upgrade to rubocop latest
19
+ * Add `TargetRubyVersion: 2.6` to rubocop config (based on
20
+ https://www.ruby-lang.org/en/downloads/branches/ oldest "normal
21
+ maintenance" version)
22
+ * Add `required_ruby_version` to gemspec
23
+ * addresses rubocop violations
24
+
25
+ * Update WSDL endpoint URL as recommended by TaxCloud to
26
+ https://asmx.taxcloud.com/1.0/?wsdl - @brchristian.
27
+
28
+
29
+ ### 0.3.0 (1/9/2014)
30
+
31
+ * #19: Support Savon 2 - @drewtempelmeyer.
32
+ * Implemented Rubocop, Ruby style linter - @dblock.
33
+ * Ruby 1.8.7 and 1.9.2 are no longer supported - @dblock.
34
+
35
+
36
+ ### 0.2.2 (4/29/2013)
37
+
38
+ * Relaxed thirdparty gem dependency versions - @mperham.
39
+
40
+
41
+ ### 0.2.1 (3/3/2013)
42
+
43
+ * Fixed date formatting in API requests with localized applications -
44
+ @soulcutter.
45
+
46
+
47
+ ### 0.2.0 (11/26/2012)
48
+
49
+ * The gem is now licensed under the MIT license - @dblock.
50
+ * Raise specialized configuration and SOAP errors - @dblock.
51
+ * Added `TaxCloud::Client.ping` - @dblock.
52
+ * Returning a verified `TaxCloud::Address` from `TaxCloud::Address.verify` -
53
+ @dblock.
54
+ * Added `TaxCloud::Address.zip` that returns a 9-digit address zip code,
55
+ when available - @dblock.
56
+ * Returning a `TaxCloud::Responses::Lookup` from
57
+ `TaxCloud::Transaction.lookup` - @dblock.
58
+ * Returning transaction state, ie. `"OK"` from all other TaxCloud
59
+ transactions. Exceptions are raised on error - @dblock.
60
+ * Added support for tax codes and tax code groups lookup with
61
+ `TaxCloud::TaxCodes` and `TaxCloud::TaxCode::Groups` - @dblock.
62
+
63
+
64
+ ### 0.1.5 (5/9/2012)
65
+
66
+ * Fixed compatibility with Ruby 1.8.7 and 1.9.3, removed super from
67
+ constructors for classes which inherit from `Object` - @gfmurphy.
68
+
69
+
70
+ ### 0.1.4 (10/20/2011)
71
+
72
+ * Upgraded rdoc - @drewtempelmeyer.
73
+ * Fixed `.gemspec` dependency declaration for savon - @drewtempelmeyer.
74
+
75
+
76
+ ### 0.1.3 (9/19/2011)
77
+
78
+ * Added support for the "returned" request - @danielmorrison.
79
+ * Refactoreted tests to use vcr and webmock - @danielmorrison.
80
+
81
+
82
+ ### 0.1.0 (8/23/2011)
83
+
84
+ * Initial public release - @drewtempelmeyer.
85
+
data/CONTRIBUTORS.txt CHANGED
@@ -21,3 +21,6 @@ Contributors
21
21
 
22
22
  * Bradley Schaefer
23
23
  * Github: soulcutter
24
+
25
+ * Gary Hepting
26
+ * Github: ghepting
data/Gemfile CHANGED
@@ -1,9 +1,19 @@
1
- source "http://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
4
6
 
5
- platform :rbx do
6
- gem 'rubysl', '~> 2.0'
7
- gem 'racc'
8
- gem 'iconv'
7
+ group :development do
8
+ gem 'rubocop', '~> 0.93.1'
9
+ end
10
+
11
+ group :test do
12
+ gem 'minitest'
13
+ gem 'vcr'
14
+ gem 'webmock'
15
+ end
16
+
17
+ group :development, :test do
18
+ gem 'rake', '~>12.2.1'
9
19
  end
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2011-2020 Drew Tempelmeyer & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,200 @@
1
+ # TaxCloud
2
+
3
+ [![Build Status](https://github.com/txcrb/tax_cloud/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/txcrb/tax_cloud/actions)
4
+
5
+ [TaxCloud](http://www.taxcloud.com) is a free service to calculate sales tax
6
+ and generate tax reports. The `tax_cloud` gem allows you to easily integrate
7
+ with TaxCloud's API.
8
+
9
+ ### Getting Started
10
+ Create a [TaxCloud](http://www.taxcloud.com) merchant account at
11
+ http://www.taxcloud.net. Add a website to your account under
12
+ [Locations](https://taxcloud.net/account/locations). This will generate an API
13
+ ID and API Key that you will need to use the service.
14
+
15
+ [TaxCloud](http://www.taxcloud.com) also offers an optional address
16
+ verification API. To use it, you need a USPS (United States Postal Service)
17
+ Address API Username. To obtain your USPS Username:
18
+ 1. Go through the Web Tools API Portal registration process at
19
+ https://registration.shippingapis.com/
20
+ 2. Once you have registered for your account, you will receive an email with
21
+ your USPS username and password.
22
+ 3. Enter your USPS username in your TaxCloud initializer (see below).
23
+
24
+
25
+ ### Setup
26
+ Add the gem to your Gemfile.
27
+
28
+ ```ruby
29
+ gem 'tax_cloud'
30
+ ```
31
+
32
+ Configure your environment. For example, create an initializer in Rails in
33
+ `config/initializers/tax_cloud.rb`.
34
+
35
+ ```ruby
36
+ TaxCloud.configure do |config|
37
+ config.api_login_id = 'your_tax_cloud_api_login_id'
38
+ config.api_key = 'your_tax_cloud_api_key'
39
+ config.usps_username = 'your_usps_username' # optional
40
+ config.open_timeout = 1 # optional
41
+ config.read_timeout = 1 # optional
42
+ end
43
+ ```
44
+
45
+ The `open_timeout` and `read_timeout` options are used to specify waiting time
46
+ for the TaxCloud web service response in seconds. Default values:
47
+ `open_timeout = 2` and `read_timeout = 2`.
48
+
49
+ ### Using TaxCloud
50
+ Define the destination and origin addresses using `TaxCloud::Address`.
51
+
52
+ ```ruby
53
+ origin = TaxCloud::Address.new(
54
+ address1: '162 East Avenue',
55
+ address2: 'Third Floor',
56
+ city: 'Norwalk',
57
+ state: 'CT',
58
+ zip5: '06851'
59
+ )
60
+ destination = TaxCloud::Address.new(
61
+ address1: '3121 West Government Way',
62
+ address2: 'Suite 2B',
63
+ city: 'Seattle',
64
+ state: 'WA',
65
+ zip5: '98199'
66
+ )
67
+ ```
68
+
69
+ Create your Transaction and set up your cart items
70
+
71
+ ```ruby
72
+ transaction = TaxCloud::Transaction.new(
73
+ customer_id: '1',
74
+ cart_id: '1',
75
+ origin: origin,
76
+ destination: destination
77
+ )
78
+ transaction.cart_items << TaxCloud::CartItem.new(
79
+ index: 0,
80
+ item_id: 'SKU-100',
81
+ tic: TaxCloud::TaxCodes::GENERAL,
82
+ price: 10.00,
83
+ quantity: 1
84
+ )
85
+ lookup = transaction.lookup # this will return a TaxCloud::Responses::Lookup instance
86
+ lookup.tax_amount # total tax amount
87
+ lookup.cart_items.each do |cart_item|
88
+ cart_item.tax_amount # tax for a single item
89
+ end
90
+ ```
91
+
92
+ After you've authorized and captured the transaction via your merchant
93
+ account, you should do the same with TaxCloud for maintaining accurate tax
94
+ information.
95
+
96
+ ```ruby
97
+ transaction.order_id = 100
98
+ transaction.authorized_with_capture # returns "OK" or raises an error
99
+ ```
100
+
101
+ Later, you may need to mark some cart items as returned. TaxCloud will ignore
102
+ any cart items that you don't include.
103
+
104
+ ```ruby
105
+ transaction.order_id = 100
106
+ transaction.cart_items << TaxCloud::CartItem.new(
107
+ index: 0,
108
+ item_id: 'SKU-100',
109
+ tic: TaxCloud::TaxCodes::GENERAL,
110
+ price: 10.00,
111
+ quantity: 1
112
+ )
113
+ transaction.returned # returns "OK" or raises an error
114
+ ```
115
+
116
+ ### Verifying Addresses
117
+
118
+ [TaxCloud](http://www.taxcloud.com) optionally integrates with the USPS
119
+ Address API. An address can be verified, which can also yield a 9-digit zip
120
+ code that helps determine a more accurate tax rate.
121
+
122
+ ```ruby
123
+ address = TaxCloud::Address.new({
124
+ address1: '888 6th Ave',
125
+ city: 'New York',
126
+ state: 'New York',
127
+ zip5: '10001'
128
+ })
129
+
130
+ verified_address = address.verify
131
+ verified_address.zip5 # 10001
132
+ verified_address.zip4 # 3502
133
+ verified_address.zip # 10001-3502
134
+ ```
135
+
136
+ ### Tax Codes
137
+ [TaxCloud](http://www.taxcloud.com) maintains a list of all Taxability
138
+ Information Codes or TICs, which can be found at https://taxcloud.net/tic.
139
+
140
+ You can obtain all tax codes as well as lookup a tax code by ID.
141
+
142
+ ```ruby
143
+ TaxCloud::TaxCodes.all # a hash of all codes
144
+ tax_code = TaxCloud::TaxCodes[TaxCloud::TaxCodes::DIRECT_MAIL_RELATED]
145
+ tax_code.ticid # 11000 or TaxCloud::TaxCodes::DIRECT_MAIL_RELATED
146
+ tax_code.description # "Direct-mail related"
147
+ ```
148
+
149
+ Tax codes are organized in groups.
150
+
151
+ ```ruby
152
+ TaxCloud::TaxCode::Groups.all # a hash of all groups
153
+ tax_code_group = TaxCloud::TaxCode::Groups[TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS]
154
+ tax_code_group.group_id # 3 or TaxCloud::TaxCode::Groups::SCHOOL_RELATED_PRODUCTS
155
+ tax_code_group.description # School Related Products
156
+ tax_code_group.tax_codes # a hash of all codes in this group
157
+ ```
158
+
159
+ Tax code constants are defined in `tax_code_constants.rb` and tax code group
160
+ constants in `tax_code_group_constants.rb`. These files can be generated by
161
+ running the following rake tasks.
162
+
163
+ ```
164
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_codes
165
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... tax_cloud:tax_code_groups
166
+ ```
167
+
168
+ ### Tax States
169
+ TaxCloud manages a list of states in which you can calculate sales tax. The
170
+ default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement)
171
+ states enabled. All other states will return $0 for tax values. To enable
172
+ other states, go to https://taxcloud.com/go/states-management/. You can find
173
+ more information about SSUTA
174
+ [here](http://www.streamlinedsalestax.org/index.php?page=About-Us).
175
+
176
+ ### Running Tests
177
+ * VCR and WebMock are used to replay requests and avoid hitting the API each
178
+ time. To refresh the mocks, simply delete the `test/cassettes` directory.
179
+ * Run tests.
180
+ rake test
181
+
182
+ * If you need to record new requests against TaxCloud, set your keys first.
183
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... rake test
184
+
185
+ The mocks will filter out your configuration details.
186
+
187
+
188
+ ### Bugs, fixes, etc
189
+ * Fork.
190
+ * Write test(s).
191
+ * Fix.
192
+ * Commit.
193
+ * Submit pull request.
194
+
195
+
196
+ ### License
197
+
198
+ Copyright Drew Tempelmeyer and contributors, 2011-2020.
199
+
200
+ This gem is licensed under the MIT license.
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
- require 'rdoc/task'
4
-
5
- gemspec = eval(File.read(Dir["*.gemspec"].first))
5
+ require 'vcr'
6
6
 
7
7
  Rake::TestTask.new(:test) do |test|
8
8
  test.libs << 'lib' << 'test'
@@ -10,26 +10,12 @@ Rake::TestTask.new(:test) do |test|
10
10
  test.verbose = false
11
11
  end
12
12
 
13
- RDoc::Task.new do |rd|
14
- README = 'README.rdoc'
15
- rd.main = README
16
- rd.rdoc_files.include(README, 'CHANGELOG.rdoc', 'LICENSE.rdoc', "lib/**/*.rb")
17
- rd.rdoc_dir = 'doc'
18
- rd.title = 'tax_cloud'
19
- end
20
-
21
- desc "Validate the gemspec."
22
- task :gemspec do
23
- puts gemspec.validate
24
- end
25
-
26
13
  load 'lib/tasks/tax_cloud.rake'
27
14
  load 'lib/tasks/tax_codes.rake'
28
15
  load 'lib/tasks/tax_code_groups.rake'
29
-
30
16
  load 'vcr/tasks/vcr.rake'
31
17
 
32
18
  require 'rubocop/rake_task'
33
- Rubocop::RakeTask.new(:rubocop)
19
+ RuboCop::RakeTask.new(:rubocop)
34
20
 
35
- task default: [:rubocop, :test]
21
+ task default: %i[rubocop test]
@@ -16,7 +16,7 @@ en:
16
16
  \_\_end\n"
17
17
  missing_config_option:
18
18
  message: "Missing configuration option: %{name}."
19
- summary: "A configuration option was not provided when configuration TaxCloud."
19
+ summary: "A configuration option was not provided when configuring TaxCloud."
20
20
  resolution: "Review your `TaxCloud.configure` code. Are you using an environment
21
21
  variable that has not been set?"
22
22
  soap_error:
@@ -31,4 +31,4 @@ en:
31
31
  api_error:
32
32
  message: "%{message}"
33
33
  summary: "The TaxCloud server returned an error in the response: `%{raw}`"
34
- resolution: "Check the request parameters."
34
+ resolution: "Check the request parameters."
data/lib/hash.rb CHANGED
@@ -1,9 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Hash #:nodoc: all
2
4
  # Downcase the keys. Use this because <tt>TaxCloud::Address.verify</tt> requires downcased keys
3
5
  def downcase_keys
4
- reduce({}) do |h, (k, v)|
5
- h[k.downcase] = v
6
- h
7
- end
6
+ transform_keys(&:downcase)
8
7
  end
9
8
  end
@@ -1,20 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tax_cloud'
2
4
 
3
5
  namespace :tax_cloud do
4
-
5
- desc "Configure TaxCloud."
6
+ desc 'Configure TaxCloud.'
6
7
  task :configure do
7
8
  unless TaxCloud.configured?
8
9
  TaxCloud.configure do |config|
9
10
  config.api_login_id = ENV['TAXCLOUD_API_LOGIN_ID']
10
11
  config.api_key = ENV['TAXCLOUD_API_KEY']
11
12
  config.usps_username = ENV['TAXCLOUD_USPS_USERNAME']
12
- end
13
+ end
13
14
  Savon.configure do |config|
14
15
  config.log = false
15
16
  end
16
17
  HTTPI.log = false
17
18
  end
18
19
  end
19
-
20
20
  end
@@ -1,13 +1,14 @@
1
- namespace :tax_cloud do
1
+ # frozen_string_literal: true
2
2
 
3
- desc "Generate tax code groups."
4
- task :tax_code_groups => :configure do
5
- filename = "lib/tax_cloud/tax_code_group_constants.rb"
3
+ namespace :tax_cloud do
4
+ desc 'Generate tax code groups.'
5
+ task tax_code_groups: :configure do
6
+ filename = 'lib/tax_cloud/tax_code_group_constants.rb'
6
7
 
7
8
  begin
8
9
  groups = TaxCloud::TaxCode::Groups.all.values
9
10
 
10
- File.open filename, "wt" do |f|
11
+ File.open filename, 'wt' do |f|
11
12
  f.write "module TaxCloud\n"
12
13
  f.write " class TaxCode\n"
13
14
  f.write " # Tax Code Groups.\n"
@@ -16,9 +17,9 @@ namespace :tax_cloud do
16
17
  groups.each do |group|
17
18
  puts " #{group.description}"
18
19
  code = group.description.upcase
19
- code.gsub! /[^A-Z0-9]/, '_'
20
- code.gsub! /_$/, ''
21
- code.gsub! /\_+/, '_'
20
+ code.gsub!(/[^A-Z0-9]/, '_')
21
+ code.gsub!(/_$/, '')
22
+ code.gsub!(/_+/, '_')
22
23
  f.write " \# #{group.description}\n"
23
24
  f.write " #{code} = #{group.group_id}\n"
24
25
  end
@@ -29,11 +30,10 @@ namespace :tax_cloud do
29
30
  end
30
31
 
31
32
  puts "Done, #{filename}."
32
- rescue => e
33
- puts "ERROR: Unable to generate a new list of tax codes."
33
+ rescue StandardError => e
34
+ puts 'ERROR: Unable to generate a new list of tax codes.'
34
35
  puts e.message
35
36
  raise e
36
37
  end
37
38
  end
38
-
39
39
  end
@@ -1,15 +1,16 @@
1
- namespace :tax_cloud do
1
+ # frozen_string_literal: true
2
2
 
3
- desc "Generate tax codes."
4
- task :tax_codes => :configure do
5
- filename = "lib/tax_cloud/tax_code_constants.rb"
3
+ namespace :tax_cloud do
4
+ desc 'Generate tax codes.'
5
+ task tax_codes: :configure do
6
+ filename = 'lib/tax_cloud/tax_code_constants.rb'
6
7
 
7
8
  begin
8
9
  groups = TaxCloud::TaxCode::Groups.all.values
9
10
  groups_and_tax_codes = Hash[groups.map do |group|
10
- [ group, group.tax_codes.values ]
11
+ [group, group.tax_codes.values]
11
12
  end]
12
- File.open filename, "wt" do |f|
13
+ File.open filename, 'wt' do |f|
13
14
  f.write "module TaxCloud\n"
14
15
  f.write " # Tax Codes.\n"
15
16
  f.write " class TaxCodes\n"
@@ -20,9 +21,9 @@ namespace :tax_cloud do
20
21
  f.write " \# #{group.description}\n\n"
21
22
  tax_codes.each do |tax_code|
22
23
  code = tax_code.description.upcase
23
- code.gsub! /[^A-Z0-9]/, '_'
24
- code.gsub! /\_+$/, ''
25
- code.gsub! /\_+/, '_'
24
+ code.gsub!(/[^A-Z0-9]/, '_')
25
+ code.gsub!(/_+$/, '')
26
+ code.gsub!(/_+/, '_')
26
27
  # avoid duplicates
27
28
  code_id = codes[code] ? "#{code}_#{codes[code]}" : code
28
29
  codes[code] = (codes[code] || 0) + 1
@@ -35,11 +36,10 @@ namespace :tax_cloud do
35
36
  f.write "end\n"
36
37
  end
37
38
  puts "Done, #{filename}."
38
- rescue => e
39
- puts "ERROR: Unable to generate a new list of tax codes."
39
+ rescue StandardError => e
40
+ puts 'ERROR: Unable to generate a new list of tax codes.'
40
41
  puts e.message
41
42
  raise e
42
43
  end
43
-
44
44
  end
45
45
  end