summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2021-02-08 16:50:56 -0800
committerGitHub <noreply@github.com>2021-02-08 16:50:56 -0800
commit6e9ff3c16c705cb75b55b4cfb9f66379bcad45a7 (patch)
tree14c1f3a3d59ec9df9eb7b601cbe146bf14ad3e2a
parentb8e1db2f128312b7d2a6923c2fe2424df70385c2 (diff)
parent338d38d00a3e444aaeddc757e508d0f34d811209 (diff)
Merge pull request #34 from nvandoorn/33-put-api-version-in-request-headers
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/super_good/solidus_taxjar/api.rb4
-rw-r--r--spec/super_good/solidus_taxjar/api_spec.rb17
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 }