diff options
author | Nicholas Van Doorn <vandoorn.nick@gmail.com> | 2021-03-24 11:43:37 -0700 |
---|---|---|
committer | Nicholas Van Doorn <vandoorn.nick@gmail.com> | 2021-03-24 11:43:37 -0700 |
commit | 84db881c4340be3b7fa3f0ed6a80e1133a1c70fa (patch) | |
tree | c62da3b8669f608483fed3466abaf09d1e69f1bc /lib/super_good/solidus_taxjar/api.rb | |
parent | b8dac4791bb6399f3122f1a22aff269a9ede9fea (diff) |
Fix `.default_taxjar_client`
In #34, we modified `.default_taxjar_client` to include the API version,
and then the name of the plugin, but we also introduced a critical bug.
`Taxjar::Client#set_api_config` returns a hash and not the TaxJar
client, so it is not safe to chain the method call. As such, we add a
spec to cover this case and patch the class method.
Co-authored-by: Noah Silvera <noah@super.gd>
Diffstat (limited to 'lib/super_good/solidus_taxjar/api.rb')
-rw-r--r-- | lib/super_good/solidus_taxjar/api.rb | 6 |
1 files changed, 4 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) |