summaryrefslogtreecommitdiff
path: root/lib/super_good
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-06-25 14:52:23 -0700
committerGitHub <noreply@github.com>2019-06-25 14:52:23 -0700
commit0fbcc56f09fd7d99b552f91750ccb82f6b5633b9 (patch)
tree9b209d630b1d21d4b209686e70d4af95a141f13f /lib/super_good
parent2950a77438e5ab6bc62f8404fdf9689a46cfce7b (diff)
parentf6fbe918e4471898c6060844a5ab581c885a9b49 (diff)
Merge pull request #15 from SuperGoodSoft/logging
Logging!
Diffstat (limited to 'lib/super_good')
-rw-r--r--lib/super_good/solidus_taxjar.rb2
-rw-r--r--lib/super_good/solidus_taxjar/api.rb8
-rw-r--r--lib/super_good/solidus_taxjar/api_params.rb7
3 files changed, 16 insertions, 1 deletions
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb
index 1016397..9318181 100644
--- a/lib/super_good/solidus_taxjar.rb
+++ b/lib/super_good/solidus_taxjar.rb
@@ -16,6 +16,7 @@ module SuperGood
attr_accessor :discount_calculator
attr_accessor :exception_handler
attr_accessor :line_item_tax_label_maker
+ attr_accessor :logging_enabled
attr_accessor :shipping_calculator
attr_accessor :shipping_tax_label_maker
attr_accessor :taxable_address_check
@@ -30,6 +31,7 @@ module SuperGood
Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}"
}
self.line_item_tax_label_maker = ->(taxjar_line_item, spree_line_item) { "Sales Tax" }
+ self.logging_enabled = false
self.shipping_calculator = ->(order) { order.shipment_total }
self.shipping_tax_label_maker = ->(shipment, shipping_tax) { "Sales Tax" }
self.taxable_address_check = ->(address) { true }
diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb
index 7309a64..0d182ce 100644
--- a/lib/super_good/solidus_taxjar/api.rb
+++ b/lib/super_good/solidus_taxjar/api.rb
@@ -13,7 +13,13 @@ module SuperGood
end
def tax_for(order)
- taxjar_client.tax_for_order APIParams.order_params(order)
+ taxjar_client.tax_for_order(APIParams.order_params(order)).tap do |taxes|
+ next unless SuperGood::SolidusTaxJar.logging_enabled
+
+ Rails.logger.info(
+ "TaxJar response for #{order.number}: #{taxes.to_h.inspect}"
+ )
+ end
end
def tax_rates_for(address)
diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb
index 7c6942f..5412232 100644
--- a/lib/super_good/solidus_taxjar/api_params.rb
+++ b/lib/super_good/solidus_taxjar/api_params.rb
@@ -8,6 +8,13 @@ module SuperGood
.merge(order_address_params(order.tax_address))
.merge(line_items_params(order.line_items))
.merge(shipping: order.shipment_total)
+ .tap do |params|
+ next unless SuperGood::SolidusTaxJar.logging_enabled
+
+ Rails.logger.info(
+ "TaxJar params: #{params.inspect}"
+ )
+ end
end
def address_params(address)