diff options
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/api.rb | 4 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/api_spec.rb | 17 |
3 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index be3cc4d..75cdefb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - [#21](https://github.com/SuperGoodSoft/solidus_taxjar/pull/21) Migrated project to `solidus_dev_support` - [#22](https://github.com/SuperGoodSoft/solidus_taxjar/pull/22) Added support for TaxJar address validation API through `SuperGood::SolidusTaxJar::Addresses` class +- [#34](https://github.com/SuperGoodSoft/solidus_taxjar/pull/34) Include API version in request headers ## v0.17.1 diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index 9a8ba90..a1d1af5 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -5,7 +5,9 @@ module SuperGood ::Taxjar::Client.new( api_key: ENV.fetch("TAXJAR_API_KEY"), api_url: ENV.fetch("TAXJAR_API_URL") { "https://api.taxjar.com" } # Sandbox URL: https://api.sandbox.taxjar.com - ) + ).set_api_config('headers', { + 'x-api-version' => '2020-08-07' + }) end def initialize(taxjar_client: self.class.default_taxjar_client) diff --git a/spec/super_good/solidus_taxjar/api_spec.rb b/spec/super_good/solidus_taxjar/api_spec.rb index 7fab505..0244536 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -1,6 +1,23 @@ require "spec_helper" RSpec.describe SuperGood::SolidusTaxJar::API do + describe ".new" do + subject { described_class.new } + + let(:dummy_client) { instance_double ::Taxjar::Client } + + before do + ENV["TAXJAR_API_KEY"] = 'taxjar_api_token' + end + + it "puts the API version in the header" do + expect_any_instance_of(::Taxjar::Client).to receive(:set_api_config).with('headers', { + 'x-api-version' => '2020-08-07' + }) + subject + end + end + describe "#tax_for" do subject { api.tax_for order } |