diff options
-rw-r--r-- | lib/super_good/solidus_taxjar/api.rb | 6 | ||||
-rw-r--r-- | spec/super_good/solidus_taxjar/api_spec.rb | 13 |
2 files changed, 17 insertions, 2 deletions
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index ca6ff6c..096994b 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -2,13 +2,15 @@ module SuperGood module SolidusTaxjar class Api def self.default_taxjar_client - ::Taxjar::Client.new( + client = ::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', { + ) + client.set_api_config('headers', { 'x-api-version' => '2020-08-07', 'plugin' => 'supergoodsolidustaxjar' }) + client 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 61a2c86..94f214d 100644 --- a/spec/super_good/solidus_taxjar/api_spec.rb +++ b/spec/super_good/solidus_taxjar/api_spec.rb @@ -17,6 +17,19 @@ RSpec.describe SuperGood::SolidusTaxjar::Api do end end + describe ".default_taxjar_client" do + subject { described_class.default_taxjar_client } + + before do + ENV["TAXJAR_API_KEY"] = 'taxjar_api_token' + end + + it "returns an instance of the TaxJar client" do + expect(subject).to be_an_instance_of(::Taxjar::Client) + end + end + + describe "#tax_for" do subject { api.tax_for order } |