tax_cloud 0.5.0 → 0.7.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.
data/CHANGELOG.md CHANGED
@@ -1,85 +1,74 @@
1
- ### 0.5.0 (7/21/2023)
1
+ # Changelog
2
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.
3
+ ## 0.7.0 (2026/11/25)
9
4
 
5
+ * [#58](https://github.com/txcrb/tax_cloud/pull/58): Test on Ruby 2.6, 3.4, and 4.0 with current GitHub Actions, unpin Rake, which fails to load on Ruby 4.0, and keep Rack below 3 for httpi on Ruby 2.x - [@dblock](https://github.com/dblock).
6
+ * [#59](https://github.com/txcrb/tax_cloud/pull/59): Lint Markdown, YAML, and spelling with rubocop-md, rubocop-prose, rubocop-spellcheck, and rubocop-yaml in a separate Lint workflow, and clean up documentation - [@dblock](https://github.com/dblock).
7
+ * [#60](https://github.com/txcrb/tax_cloud/pull/60): Run CI pushes only on the default branch, cancel superseded pull request runs, and bound job times - [@dblock](https://github.com/dblock).
8
+ * [#62](https://github.com/txcrb/tax_cloud/pull/62): Release with ruby-gem-release through a manually dispatched GitHub Actions workflow and RubyGems Trusted Publishing - [@dblock](https://github.com/dblock).
9
+ * [#64](https://github.com/txcrb/tax_cloud/pull/64): Raise `TaxCloud::Errors::MissingCartItems` when looking up a transaction without cart items - [@dblock](https://github.com/dblock).
10
+ * [#65](https://github.com/txcrb/tax_cloud/pull/65): Check pull requests with Danger, including CHANGELOG entries with danger-changelog, and report results in a pull request comment with danger-pr-comment - [@dblock](https://github.com/dblock).
10
11
 
11
- ### 0.4.0 (12/7/2020)
12
+ ## 0.6.0 (2023/12/15)
12
13
 
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
14
+ * Add Residential Delivery Indicator (rdi) to `TaxCloud::Address` on successful address verification - @nononoy.
24
15
 
25
- * Update WSDL endpoint URL as recommended by TaxCloud to
26
- https://asmx.taxcloud.com/1.0/?wsdl - @brchristian.
16
+ ## 0.5.0 (2023/7/21)
27
17
 
18
+ * Update README, CHANGELOG, and LICENSE from RDoc to Markdown - @brchristian.
19
+ * Migrate from Travis CI to GitHub Actions - @rchekaluk.
20
+ * Update WSDL endpoint URL as recommended by TaxCloud to https://api.taxcloud.com/1.0/?wsdl - @mrmarcondes.
28
21
 
29
- ### 0.3.0 (1/9/2014)
22
+ ## 0.4.0 (2020/12/7)
30
23
 
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.
24
+ * Add `open_timeout` and `read_timeout` options into configuration - @ka8725.
25
+ * Switch to using BigDecimal for `tax_amount` to avoid floating point arithmetic errors - @paulhenrich.
26
+ * Require Ruby 2.6.0+.
27
+ * Upgrade to RuboCop latest:
28
+ * Add `TargetRubyVersion: 2.6` to RuboCop config (based on https://www.ruby-lang.org/en/downloads/branches/ oldest "normal maintenance" version).
29
+ * Add `required_ruby_version` to gemspec.
30
+ * Address RuboCop violations.
31
+ * Update WSDL endpoint URL as recommended by TaxCloud to https://asmx.taxcloud.com/1.0/?wsdl - @brchristian.
34
32
 
33
+ ## 0.3.0 (2014/1/9)
35
34
 
36
- ### 0.2.2 (4/29/2013)
35
+ * [#19](https://github.com/txcrb/tax_cloud/issues/19): Support Savon 2 - @drewtempelmeyer.
36
+ * Implemented RuboCop, Ruby style linter - @dblock.
37
+ * Ruby 1.8.7 and 1.9.2 are no longer supported - @dblock.
37
38
 
38
- * Relaxed thirdparty gem dependency versions - @mperham.
39
+ ## 0.2.2 (2013/4/29)
39
40
 
41
+ * Relaxed third-party gem dependency versions - @mperham.
40
42
 
41
- ### 0.2.1 (3/3/2013)
43
+ ## 0.2.1 (2013/3/3)
42
44
 
43
- * Fixed date formatting in API requests with localized applications -
44
- @soulcutter.
45
+ * Fixed date formatting in API requests with localized applications - @soulcutter.
45
46
 
47
+ ## 0.2.0 (2012/11/26)
46
48
 
47
- ### 0.2.0 (11/26/2012)
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` - @dblock.
53
+ * Added `TaxCloud::Address.zip` that returns a 9-digit address zip code, when available - @dblock.
54
+ * Returning a `TaxCloud::Responses::Lookup` from `TaxCloud::Transaction.lookup` - @dblock.
55
+ * Returning transaction state, i.e. `"OK"` from all other TaxCloud transactions. Exceptions are raised on error - @dblock.
56
+ * Added support for tax codes and tax code groups lookup with `TaxCloud::TaxCodes` and `TaxCloud::TaxCode::Groups` - @dblock.
48
57
 
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.
58
+ ## 0.1.5 (2012/5/9)
62
59
 
60
+ * Fixed compatibility with Ruby 1.8.7 and 1.9.3, removed super from constructors for classes which inherit from `Object` - @gfmurphy.
63
61
 
64
- ### 0.1.5 (5/9/2012)
62
+ ## 0.1.4 (2011/10/20)
65
63
 
66
- * Fixed compatibility with Ruby 1.8.7 and 1.9.3, removed super from
67
- constructors for classes which inherit from `Object` - @gfmurphy.
64
+ * Upgraded RDoc - @drewtempelmeyer.
65
+ * Fixed `.gemspec` dependency declaration for Savon - @drewtempelmeyer.
68
66
 
67
+ ## 0.1.3 (2011/9/19)
69
68
 
70
- ### 0.1.4 (10/20/2011)
69
+ * Added support for the "returned" request - @danielmorrison.
70
+ * Refactored tests to use VCR and WebMock - @danielmorrison.
71
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.
72
+ ## 0.1.0 (2011/8/23)
85
73
 
74
+ * Initial public release - @drewtempelmeyer.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,88 @@
1
+ # Contributing to TaxCloud
2
+
3
+ This gem is the work of [many contributors](https://github.com/txcrb/tax_cloud/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/txcrb/tax_cloud/pulls), [propose features, ask questions, and discuss issues](https://github.com/txcrb/tax_cloud/issues).
4
+
5
+ ## Fork the Project
6
+
7
+ Fork the [project on GitHub](https://github.com/txcrb/tax_cloud) and check out your copy.
8
+
9
+ ```sh
10
+ git clone https://github.com/contributor/tax_cloud.git
11
+ cd tax_cloud
12
+ git remote add upstream https://github.com/txcrb/tax_cloud.git
13
+ ```
14
+
15
+ ## Create a Topic Branch
16
+
17
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
18
+
19
+ ```sh
20
+ git checkout master
21
+ git pull upstream master
22
+ git checkout -b my-feature-branch
23
+ ```
24
+
25
+ ## Run Tests
26
+
27
+ Ensure that you can build the project and run tests.
28
+
29
+ ```sh
30
+ bundle install
31
+ bundle exec rake
32
+ ```
33
+
34
+ VCR and WebMock replay recorded TaxCloud responses from `test/cassettes`, so tests do not call the API. To record new requests against TaxCloud, delete the cassettes you want to refresh and set your keys first. The cassettes filter out your configuration details.
35
+
36
+ ```sh
37
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... bundle exec rake test
38
+ ```
39
+
40
+ ## Lint
41
+
42
+ `bundle exec rake lint` checks Ruby, Ruby examples in Markdown, YAML, and spelling with RuboCop, [rubocop-md](https://github.com/rubocop/rubocop-md), [rubocop-prose](https://github.com/dblock/rubocop-prose), [rubocop-spellcheck](https://github.com/dblock/rubocop-spellcheck), and [rubocop-yaml](https://github.com/dblock/rubocop-yaml). The linters install only on MRI Ruby 3.3 and newer, where `bundle exec rake` runs lint and tests; on older Rubies it runs tests only. Add reviewed project vocabulary to `.spellcheck.txt`.
43
+
44
+ ## Write Tests
45
+
46
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add to [test](test).
47
+
48
+ ## Write Code
49
+
50
+ Implement your feature or bug fix.
51
+
52
+ ## Write Documentation
53
+
54
+ Document any external behavior in the [README](README.md).
55
+
56
+ ## Update Changelog
57
+
58
+ Add a line to [CHANGELOG](CHANGELOG.md) under *Next*. Make it look like every other line, including your name and link to your GitHub account. [Danger](https://danger.systems) checks the entry on every pull request and reports problems in a pull request comment.
59
+
60
+ ## Commit Changes
61
+
62
+ Make sure git knows your name and email address.
63
+
64
+ ```sh
65
+ git config --global user.name "Your Name"
66
+ git config --global user.email "contributor@example.com"
67
+ ```
68
+
69
+ Writing good commit logs is important. A commit log should describe what changed and why.
70
+
71
+ ```sh
72
+ git add ...
73
+ git commit
74
+ ```
75
+
76
+ ## Push
77
+
78
+ ```sh
79
+ git push origin my-feature-branch
80
+ ```
81
+
82
+ ## Make a Pull Request
83
+
84
+ Go to https://github.com/contributor/tax_cloud and select your feature branch. Click the "Pull Request" button and fill out the form. Pull requests are usually reviewed within a few days.
85
+
86
+ ## Thank You
87
+
88
+ Please do know that we really appreciate and value your time and work. We love you, really.
data/CONTRIBUTORS.txt CHANGED
@@ -5,22 +5,22 @@ Lead Developers
5
5
  * Drew Tempelmeyer
6
6
  * Twitter: @tempelmeyer
7
7
  * App.net: @tempelmeyer
8
- * Github: drewtempelmeyer
8
+ * GitHub: drewtempelmeyer
9
9
 
10
10
  * Daniel Doubrovkine
11
11
  * Twitter: @dblockdotorg
12
- * Github: dblock
12
+ * GitHub: dblock
13
13
 
14
14
  Contributors
15
15
  =======================
16
16
  * Daniel Morrison
17
- * Github: danielmorrison
17
+ * GitHub: danielmorrison
18
18
 
19
19
  * George F Murphy
20
- * Github: gfmurphy
20
+ * GitHub: gfmurphy
21
21
 
22
22
  * Bradley Schaefer
23
- * Github: soulcutter
23
+ * GitHub: soulcutter
24
24
 
25
25
  * Gary Hepting
26
- * Github: ghepting
26
+ * GitHub: ghepting
data/Dangerfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ danger.import_dangerfile(gem: 'danger-pr-comment')
4
+
5
+ # Released sections predate the current CHANGELOG format, so only check lines a pull request adds.
6
+ changelog.only_added = true
7
+ changelog.check!
data/Gemfile CHANGED
@@ -5,15 +5,29 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development do
8
- gem 'rubocop', '~> 0.93.1'
8
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3')
9
+ gem 'commonmarker', '~> 2.10', require: false
10
+ gem 'danger', '~> 9.6', require: false
11
+ gem 'danger-changelog', '~> 0.10', require: false
12
+ gem 'danger-pr-comment', '~> 0.3', require: false
13
+ gem 'rubocop', '~> 1.92'
14
+ gem 'rubocop-md', '~> 3.0', require: false
15
+ gem 'rubocop-prose', '~> 0.2', require: false
16
+ gem 'rubocop-rake', '~> 0.7', require: false
17
+ gem 'rubocop-spellcheck', '~> 0.2', require: false
18
+ gem 'rubocop-yaml', '~> 0.1.0', require: false
19
+ gem 'ruby-gem-release', '0.9.0', require: false
20
+ end
9
21
  end
10
22
 
11
23
  group :test do
12
24
  gem 'minitest'
25
+ # httpi 3.0.1, the newest httpi for Ruby < 3.0, does not support Rack 3.
26
+ gem 'rack', '< 3' if RUBY_VERSION < '3.0'
13
27
  gem 'vcr'
14
28
  gem 'webmock'
15
29
  end
16
30
 
17
31
  group :development, :test do
18
- gem 'rake', '~>12.2.1'
32
+ gem 'rake'
19
33
  end
data/LICENSE.md CHANGED
@@ -2,20 +2,8 @@ MIT License
2
2
 
3
3
  Copyright (c) 2011-2020 Drew Tempelmeyer & Contributors
4
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:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
14
8
 
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.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,52 +1,38 @@
1
1
  # TaxCloud
2
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)
3
+ [![Test](https://github.com/txcrb/tax_cloud/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/txcrb/tax_cloud/actions/workflows/test.yml) [![Lint](https://github.com/txcrb/tax_cloud/actions/workflows/lint.yml/badge.svg?branch=master)](https://github.com/txcrb/tax_cloud/actions/workflows/lint.yml)
4
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.
5
+ [TaxCloud](http://www.taxcloud.com) is a free service to calculate sales tax and generate tax reports. The `tax_cloud` gem allows you to easily integrate with TaxCloud's API.
8
6
 
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.
7
+ ## Getting Started
14
8
 
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).
9
+ Create a [TaxCloud](http://www.taxcloud.com) merchant account at http://www.taxcloud.net. Add a website to your account under [Locations](https://taxcloud.net/account/locations). This will generate an API ID and API Key that you will need to use the service.
23
10
 
11
+ [TaxCloud](http://www.taxcloud.com) also offers an optional address verification API. To use it, you need a USPS (United States Postal Service) Address API Username. To obtain your USPS Username:
12
+
13
+ 1. Go through the Web Tools API Portal registration process at https://registration.shippingapis.com/
14
+ 2. Once you have registered for your account, you will receive an email with your USPS username and password.
15
+ 3. Enter your USPS username in your TaxCloud initializer (see [Configuration](#configuration)).
16
+
17
+ ## Installation
24
18
 
25
- ### Setup
26
19
  Add the gem to your Gemfile.
27
20
 
28
21
  ```ruby
29
22
  gem 'tax_cloud'
30
23
  ```
31
24
 
32
- Configure your environment. For example, create an initializer in Rails in
33
- `config/initializers/tax_cloud.rb`.
25
+ ## Usage
26
+
27
+ Configure your API credentials. For example, create an initializer in Rails in `config/initializers/tax_cloud.rb`. See [Configuration](#configuration) for optional settings.
34
28
 
35
29
  ```ruby
36
30
  TaxCloud.configure do |config|
37
31
  config.api_login_id = 'your_tax_cloud_api_login_id'
38
32
  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
33
  end
43
34
  ```
44
35
 
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
36
  Define the destination and origin addresses using `TaxCloud::Address`.
51
37
 
52
38
  ```ruby
@@ -66,7 +52,7 @@ destination = TaxCloud::Address.new(
66
52
  )
67
53
  ```
68
54
 
69
- Create your Transaction and set up your cart items
55
+ Create your transaction and set up your cart items.
70
56
 
71
57
  ```ruby
72
58
  transaction = TaxCloud::Transaction.new(
@@ -84,22 +70,17 @@ transaction.cart_items << TaxCloud::CartItem.new(
84
70
  )
85
71
  lookup = transaction.lookup # this will return a TaxCloud::Responses::Lookup instance
86
72
  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
73
+ lookup.cart_items.map(&:tax_amount) # tax for each cart item
90
74
  ```
91
75
 
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.
76
+ After you've authorized and captured the transaction via your merchant account, you should do the same with TaxCloud for maintaining accurate tax information.
95
77
 
96
78
  ```ruby
97
79
  transaction.order_id = 100
98
80
  transaction.authorized_with_capture # returns "OK" or raises an error
99
81
  ```
100
82
 
101
- Later, you may need to mark some cart items as returned. TaxCloud will ignore
102
- any cart items that you don't include.
83
+ Later, you may need to mark some cart items as returned. TaxCloud will ignore any cart items that you don't include.
103
84
 
104
85
  ```ruby
105
86
  transaction.order_id = 100
@@ -115,17 +96,15 @@ transaction.returned # returns "OK" or raises an error
115
96
 
116
97
  ### Verifying Addresses
117
98
 
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.
99
+ [TaxCloud](http://www.taxcloud.com) optionally integrates with the USPS Address API. An address can be verified, which can also yield a 9-digit zip code that helps determine a more accurate tax rate.
121
100
 
122
101
  ```ruby
123
- address = TaxCloud::Address.new({
124
- address1: '888 6th Ave',
125
- city: 'New York',
126
- state: 'New York',
127
- zip5: '10001'
128
- })
102
+ address = TaxCloud::Address.new(
103
+ address1: '888 6th Ave',
104
+ city: 'New York',
105
+ state: 'New York',
106
+ zip5: '10001'
107
+ )
129
108
 
130
109
  verified_address = address.verify
131
110
  verified_address.zip5 # 10001
@@ -134,10 +113,10 @@ verified_address.zip # 10001-3502
134
113
  ```
135
114
 
136
115
  ### 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
116
 
140
- You can obtain all tax codes as well as lookup a tax code by ID.
117
+ [TaxCloud](http://www.taxcloud.com) maintains a list of all Taxability Information Codes or TICs, which can be found at https://taxcloud.net/tic.
118
+
119
+ You can obtain all tax codes as well as look up a tax code by ID.
141
120
 
142
121
  ```ruby
143
122
  TaxCloud::TaxCodes.all # a hash of all codes
@@ -156,45 +135,37 @@ tax_code_group.description # School Related Products
156
135
  tax_code_group.tax_codes # a hash of all codes in this group
157
136
  ```
158
137
 
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.
138
+ Tax code constants are defined in `tax_code_constants.rb` and tax code group constants in `tax_code_group_constants.rb`. These files can be generated by running the following Rake tasks.
162
139
 
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
140
+ ```sh
141
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... bundle exec rake tax_cloud:tax_codes
142
+ TAXCLOUD_API_LOGIN_ID=... TAXCLOUD_API_KEY=... TAXCLOUD_USPS_USERNAME=... bundle exec rake tax_cloud:tax_code_groups
166
143
  ```
167
144
 
168
145
  ### 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
146
 
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
147
+ TaxCloud manages a list of states in which you can calculate sales tax. The default setup will only have SSUTA (Streamlined Sales and Use Tax Agreement) states enabled. All other states will return $0 for tax values. To enable other states, go to https://taxcloud.com/go/states-management/. You can find more information about SSUTA on the [Streamlined Sales Tax website](http://www.streamlinedsalestax.org/index.php?page=About-Us).
148
+
149
+ ## Configuration
181
150
 
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
151
+ The following options are optional.
184
152
 
185
- The mocks will filter out your configuration details.
153
+ ```ruby
154
+ TaxCloud.configure do |config|
155
+ config.usps_username = 'your_usps_username'
156
+ config.open_timeout = 1
157
+ config.read_timeout = 1
158
+ end
159
+ ```
186
160
 
161
+ The `usps_username` option enables [address verification](#verifying-addresses). The `open_timeout` and `read_timeout` options are used to specify waiting time for the TaxCloud web service response in seconds. Default values: `open_timeout = 2` and `read_timeout = 2`.
187
162
 
188
- ### Bugs, fixes, etc
189
- * Fork.
190
- * Write test(s).
191
- * Fix.
192
- * Commit.
193
- * Submit pull request.
163
+ ## Contributing
194
164
 
165
+ See [CONTRIBUTING](CONTRIBUTING.md), [CHANGELOG](CHANGELOG.md), [RELEASING](RELEASING.md), and [CONTRIBUTORS](CONTRIBUTORS.txt).
195
166
 
196
- ### License
167
+ ## License
197
168
 
198
169
  Copyright Drew Tempelmeyer and contributors, 2011-2020.
199
170
 
200
- This gem is licensed under the MIT license.
171
+ This gem is licensed under the [MIT license](LICENSE.md).
data/RELEASING.md ADDED
@@ -0,0 +1,39 @@
1
+ # Releasing TaxCloud
2
+
3
+ There are no hard rules about when to release tax_cloud. Release bug fixes frequently, features not so frequently, and breaking API changes rarely.
4
+
5
+ Releases use [ruby-gem-release](https://github.com/dblock/ruby-gem-release) 0.9.0 through a manually dispatched [Release workflow](.github/workflows/release.yml). Keep the `ruby-gem-release` gem in [Gemfile](Gemfile) and the reusable workflow in `release.yml` pinned to the same version. The workflow publishes through RubyGems Trusted Publishing, so no RubyGems API key or one-time password is needed. It only runs from `master` in `txcrb/tax_cloud`. The local Bundler `rake release`, `release:rubygem_push`, and `release:source_control_push` tasks are disabled.
6
+
7
+ ## One-Time Setup
8
+
9
+ Before the first automated release, a maintainer must:
10
+
11
+ 1. Create the GitHub environment `release` in `txcrb/tax_cloud`, for example with `gh api --method PUT repos/txcrb/tax_cloud/environments/release`, and restrict its deployment branches to `master`. Add required reviewers to require maintainer approval before publication.
12
+ 2. At the [trusted publishers for tax_cloud](https://rubygems.org/gems/tax_cloud/trusted_publishers), add a GitHub Actions publisher with repository owner `txcrb`, repository `tax_cloud`, workflow filename `release.yml`, environment `release`, and the separate workflow repository owner `dblock` and repository `ruby-gem-release`.
13
+ 3. Allow GitHub Actions to push release commits and `v*` tags to `master`. See the upstream [setup and permissions guidance](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/RELEASING.md#one-time-setup).
14
+
15
+ Verify the setup without publishing with a [dry run](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#dry-run), which never edits files, builds, pushes, or publishes:
16
+
17
+ ```sh
18
+ gh workflow run release.yml --repo txcrb/tax_cloud --ref master -f dry-run=true
19
+ ```
20
+
21
+ ## Prepare
22
+
23
+ Start with a clean, up-to-date `master` and verify that the latest [CI checks](https://github.com/txcrb/tax_cloud/actions) pass for all supported Ruby versions. Follow semantic versioning: patch for fixes, minor for backward-compatible features, major for breaking changes. Check `VERSION` in [lib/tax_cloud/version.rb](lib/tax_cloud/version.rb) and the matching `(Next)` heading in [CHANGELOG.md](CHANGELOG.md), and change both in a pull request if needed, or pass a `version` override when dispatching.
24
+
25
+ The workflow dates the `(Next)` heading using `YYYY/MM/DD` and removes the `* Your contribution here.` placeholder; a section without notes cannot be released.
26
+
27
+ Release automation requires MRI Ruby 3.3 or newer; the release dependency and tasks are skipped on older Ruby versions and JRuby. The release test in [test/test_release.rb](test/test_release.rb) runs the actual release tasks against a local fixture with the [ruby-gem-release test helpers](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/testing.md), without contacting RubyGems or GitHub.
28
+
29
+ ## Publish
30
+
31
+ ```sh
32
+ gh workflow run release.yml --repo txcrb/tax_cloud --ref master
33
+ ```
34
+
35
+ Pass `-f version=x.y.z` to release a different version. Dispatching starts a real release; do not merge into `master` while it runs. The workflow prepares the release commit, runs lint and tests on Ruby 3.3, builds the gem, preserves recovery artifacts, publishes to RubyGems, pushes the release commit and `v` tag, and creates a GitHub Release with the changelog notes and the gem attached. It then increments the patch version, adds a new `(Next)` section, and pushes the next development commit. Verify the published version on [RubyGems](https://rubygems.org/gems/tax_cloud), the tag, the [GitHub Release](https://github.com/txcrb/tax_cloud/releases), and the next development commit.
36
+
37
+ ## Recover a Partial Release
38
+
39
+ Inspect the failed run, RubyGems, remote commits and tags, and the GitHub Release before retrying. Publication may have succeeded even if a later step failed. Never move a published tag or republish a version with different contents. Use the run's retained recovery artifacts and the upstream [recovery instructions](https://github.com/dblock/ruby-gem-release/blob/v0.9.0/docs/actions/release.md#recovery-artifacts).
data/Rakefile CHANGED
@@ -1,6 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler/gem_tasks'
4
+
5
+ if RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
6
+ Gem.loaded_specs.key?('ruby-gem-release')
7
+ require_relative 'script/release'
8
+ TaxCloudRelease.workflow.install_tasks
9
+
10
+ %w[release release:rubygem_push release:source_control_push].each do |name|
11
+ Rake::Task[name].clear
12
+ desc 'Disabled; releases run through GitHub Actions, see RELEASING.md'
13
+ task(name) { abort "#{name} is disabled; releases run through GitHub Actions, see RELEASING.md" }
14
+ end
15
+ end
4
16
  require 'rake/testtask'
5
17
  require 'vcr'
6
18
 
@@ -15,7 +27,14 @@ load 'lib/tasks/tax_codes.rake'
15
27
  load 'lib/tasks/tax_code_groups.rake'
16
28
  load 'vcr/tasks/vcr.rake'
17
29
 
18
- require 'rubocop/rake_task'
19
- RuboCop::RakeTask.new(:rubocop)
30
+ lint = RUBY_ENGINE == 'ruby' && Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.3') &&
31
+ Gem.loaded_specs.key?('rubocop')
32
+ if lint
33
+ require 'rubocop/rake_task'
34
+ RuboCop::RakeTask.new(:rubocop)
35
+
36
+ desc 'Lint Ruby, Markdown, YAML, and spelling'
37
+ task lint: :rubocop
38
+ end
20
39
 
21
- task default: %i[rubocop test]
40
+ task default: lint ? %i[rubocop test] : %i[test]
@@ -19,6 +19,10 @@ en:
19
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
+ missing_cart_items:
23
+ message: "Missing cart items."
24
+ summary: "A transaction lookup requires at least one cart item."
25
+ resolution: "Add at least one `TaxCloud::CartItem` to the transaction's `cart_items` before calling `lookup`."
22
26
  soap_error:
23
27
  message: "%{message}"
24
28
  summary: "The server returned a %{code} error."
@@ -5,7 +5,7 @@ module TaxCloud #:nodoc:
5
5
  class Address < Record
6
6
  # First line of address.
7
7
  attr_accessor :address1
8
- # Second line of adress.
8
+ # Second line of address.
9
9
  attr_accessor :address2
10
10
  # City.
11
11
  attr_accessor :city
@@ -15,6 +15,8 @@ module TaxCloud #:nodoc:
15
15
  attr_accessor :zip5
16
16
  # 4-digit Zip Code.
17
17
  attr_accessor :zip4
18
+ # Residential delivery indicator
19
+ attr_accessor :rdi
18
20
 
19
21
  # Verify this address.
20
22
  #
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TaxCloud # :nodoc:
4
+ module Errors # :nodoc:
5
+ # This error is raised when looking up a transaction without cart items.
6
+ class MissingCartItems < TaxCloudError
7
+ # Create a new error.
8
+ def initialize
9
+ super(compose_message('missing_cart_items'))
10
+ end
11
+ end
12
+ end
13
+ end