diff options
author | Noah Silvera <noah@super.gd> | 2021-03-17 11:09:17 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-17 11:09:17 -0700 |
commit | 644ea96100790569379cb1b429039df71d6b62b3 (patch) | |
tree | d842dcc04299bd4d7936118ebeb87d1071cb0347 /lib | |
parent | 6fe0283f541a7a2a8c4940f4ce3626e754a292d9 (diff) | |
parent | 68b258ac1a70346d121b57e8dfdf09a1b3df02ee (diff) |
Merge pull request #43 from Noah-Silvera/support-zeitwerk-loading0.18.0
Support zeitwerk loading (0.18.0)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/super_good/solidus_taxjar.rb | 8 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/addresses.rb | 4 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/api.rb | 20 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/api_params.rb | 12 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/calculator_helper.rb | 8 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/discount_calculator.rb | 2 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/tax_calculator.rb | 14 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/tax_rate_calculator.rb | 8 | ||||
-rw-r--r-- | lib/super_good/solidus_taxjar/version.rb | 4 |
9 files changed, 40 insertions, 40 deletions
diff --git a/lib/super_good/solidus_taxjar.rb b/lib/super_good/solidus_taxjar.rb index 7bdeb03..36b5d85 100644 --- a/lib/super_good/solidus_taxjar.rb +++ b/lib/super_good/solidus_taxjar.rb @@ -12,7 +12,7 @@ require "super_good/solidus_taxjar/discount_calculator" require "super_good/solidus_taxjar/addresses" module SuperGood - module SolidusTaxJar + module SolidusTaxjar class << self attr_accessor :cache_duration attr_accessor :cache_key @@ -28,17 +28,17 @@ module SuperGood attr_accessor :test_mode def api - ::SuperGood::SolidusTaxJar::API.new + ::SuperGood::SolidusTaxjar::Api.new end end self.cache_duration = 3.hours self.cache_key = ->(record) { record_type = record.class.name.demodulize.underscore - APIParams.send("#{record_type}_params", record).to_json + ApiParams.send("#{record_type}_params", record).to_json } self.custom_order_params = ->(order) { {} } - self.discount_calculator = ::SuperGood::SolidusTaxJar::DiscountCalculator + self.discount_calculator = ::SuperGood::SolidusTaxjar::DiscountCalculator self.exception_handler = ->(e) { Rails.logger.error "An error occurred while fetching TaxJar tax rates - #{e}: #{e.message}" } diff --git a/lib/super_good/solidus_taxjar/addresses.rb b/lib/super_good/solidus_taxjar/addresses.rb index de91af9..7fdf852 100644 --- a/lib/super_good/solidus_taxjar/addresses.rb +++ b/lib/super_good/solidus_taxjar/addresses.rb @@ -1,5 +1,5 @@ module SuperGood - module SolidusTaxJar + module SolidusTaxjar class Addresses class << self def normalize(spree_address) @@ -11,7 +11,7 @@ module SuperGood end end - def initialize(api: ::SuperGood::SolidusTaxJar.api) + def initialize(api: ::SuperGood::SolidusTaxjar.api) @api = api end diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index 5c6ab3e..ca6ff6c 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -1,6 +1,6 @@ module SuperGood - module SolidusTaxJar - class API + module SolidusTaxjar + class Api def self.default_taxjar_client ::Taxjar::Client.new( api_key: ENV.fetch("TAXJAR_API_KEY"), @@ -16,8 +16,8 @@ module SuperGood end def tax_for(order) - taxjar_client.tax_for_order(APIParams.order_params(order)).tap do |taxes| - next unless SuperGood::SolidusTaxJar.logging_enabled + 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}" @@ -26,19 +26,19 @@ module SuperGood end def tax_rate_for(address) - taxjar_client.tax_for_order(APIParams.tax_rate_address_params(address)).rate + taxjar_client.tax_for_order(ApiParams.tax_rate_address_params(address)).rate end def tax_rates_for(address) - taxjar_client.rates_for_location(*APIParams.address_params(address)) + taxjar_client.rates_for_location(*ApiParams.address_params(address)) end def create_transaction_for(order) - taxjar_client.create_order APIParams.transaction_params(order) + taxjar_client.create_order ApiParams.transaction_params(order) end def update_transaction_for(order) - taxjar_client.update_order APIParams.transaction_params(order) + taxjar_client.update_order ApiParams.transaction_params(order) end def delete_transaction_for(order) @@ -46,11 +46,11 @@ module SuperGood end def create_refund_for(reimbursement) - taxjar_client.create_refund APIParams.refund_params(reimbursement) + taxjar_client.create_refund ApiParams.refund_params(reimbursement) end def validate_spree_address(spree_address) - taxjar_client.validate_address APIParams.validate_address_params(spree_address) + taxjar_client.validate_address ApiParams.validate_address_params(spree_address) end private diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index a7d1a5b..ebf034d 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -1,6 +1,6 @@ module SuperGood - module SolidusTaxJar - module APIParams + module SolidusTaxjar + module ApiParams class << self def order_params(order) {} @@ -8,9 +8,9 @@ module SuperGood .merge(order_address_params(order.tax_address)) .merge(line_items_params(order.line_items)) .merge(shipping: shipping(order)) - .merge(SuperGood::SolidusTaxJar.custom_order_params.call(order)) + .merge(SuperGood::SolidusTaxjar.custom_order_params.call(order)) .tap do |params| - next unless SuperGood::SolidusTaxJar.logging_enabled + next unless SuperGood::SolidusTaxjar.logging_enabled Rails.logger.info( "TaxJar params for #{order.number}: #{params.inspect}" @@ -133,11 +133,11 @@ module SuperGood end def discount(line_item) - ::SuperGood::SolidusTaxJar.discount_calculator.new(line_item).discount + ::SuperGood::SolidusTaxjar.discount_calculator.new(line_item).discount end def shipping(order) - SuperGood::SolidusTaxJar.shipping_calculator.call(order) + SuperGood::SolidusTaxjar.shipping_calculator.call(order) end def sales_tax(order) diff --git a/lib/super_good/solidus_taxjar/calculator_helper.rb b/lib/super_good/solidus_taxjar/calculator_helper.rb index c4803a4..edf0754 100644 --- a/lib/super_good/solidus_taxjar/calculator_helper.rb +++ b/lib/super_good/solidus_taxjar/calculator_helper.rb @@ -1,5 +1,5 @@ module SuperGood - module SolidusTaxJar + module SolidusTaxjar module CalculatorHelper extend ActiveSupport::Concern @@ -16,14 +16,14 @@ module SuperGood end def taxable_address?(address) - SuperGood::SolidusTaxJar.taxable_address_check.call(address) + SuperGood::SolidusTaxjar.taxable_address_check.call(address) end def cache if !Rails.env.test? Rails.cache.fetch( cache_key, - expires_in: SuperGood::SolidusTaxJar.cache_duration + expires_in: SuperGood::SolidusTaxjar.cache_duration ) { yield } else yield @@ -31,7 +31,7 @@ module SuperGood end def exception_handler - SuperGood::SolidusTaxJar.exception_handler + SuperGood::SolidusTaxjar.exception_handler end end end diff --git a/lib/super_good/solidus_taxjar/discount_calculator.rb b/lib/super_good/solidus_taxjar/discount_calculator.rb index 747a9d0..e5ae91c 100644 --- a/lib/super_good/solidus_taxjar/discount_calculator.rb +++ b/lib/super_good/solidus_taxjar/discount_calculator.rb @@ -1,5 +1,5 @@ module SuperGood - module SolidusTaxJar + module SolidusTaxjar class DiscountCalculator def initialize(line_item) @line_item = line_item diff --git a/lib/super_good/solidus_taxjar/tax_calculator.rb b/lib/super_good/solidus_taxjar/tax_calculator.rb index 88eee2a..74e6f9b 100644 --- a/lib/super_good/solidus_taxjar/tax_calculator.rb +++ b/lib/super_good/solidus_taxjar/tax_calculator.rb @@ -1,15 +1,15 @@ module SuperGood - module SolidusTaxJar + module SolidusTaxjar class TaxCalculator include CalculatorHelper - def initialize(order, api: SuperGood::SolidusTaxJar.api) + def initialize(order, api: SuperGood::SolidusTaxjar.api) @order = order @api = api end def calculate - return no_tax if SuperGood::SolidusTaxJar.test_mode + return no_tax if SuperGood::SolidusTaxjar.test_mode return no_tax if incomplete_address?(order.tax_address) || order.line_items.none? return no_tax unless taxable_order? order return no_tax unless taxable_address? order.tax_address @@ -114,22 +114,22 @@ module SuperGood end def cache_key - SuperGood::SolidusTaxJar.cache_key.call(order) + SuperGood::SolidusTaxjar.cache_key.call(order) end def taxable_order?(order) - SuperGood::SolidusTaxJar.taxable_order_check.call(order) + SuperGood::SolidusTaxjar.taxable_order_check.call(order) end def shipping_tax_label(shipment, shipping_tax) - SuperGood::SolidusTaxJar.shipping_tax_label_maker.call( + SuperGood::SolidusTaxjar.shipping_tax_label_maker.call( shipment, shipping_tax ) end def line_item_tax_label(taxjar_line_item, spree_line_item) - SuperGood::SolidusTaxJar.line_item_tax_label_maker.call(taxjar_line_item, spree_line_item) + SuperGood::SolidusTaxjar.line_item_tax_label_maker.call(taxjar_line_item, spree_line_item) end end end diff --git a/lib/super_good/solidus_taxjar/tax_rate_calculator.rb b/lib/super_good/solidus_taxjar/tax_rate_calculator.rb index f9c996c..0096afc 100644 --- a/lib/super_good/solidus_taxjar/tax_rate_calculator.rb +++ b/lib/super_good/solidus_taxjar/tax_rate_calculator.rb @@ -1,14 +1,14 @@ module SuperGood - module SolidusTaxJar + module SolidusTaxjar class TaxRateCalculator include CalculatorHelper - def initialize(address, api: SuperGood::SolidusTaxJar.api) + def initialize(address, api: SuperGood::SolidusTaxjar.api) @address = address @api = api end def calculate - return no_rate if SuperGood::SolidusTaxJar.test_mode + return no_rate if SuperGood::SolidusTaxjar.test_mode return no_rate if incomplete_address?(address) return no_rate unless taxable_address?(address) cache do @@ -28,7 +28,7 @@ module SuperGood end def cache_key - SuperGood::SolidusTaxJar.cache_key.call(address) + SuperGood::SolidusTaxjar.cache_key.call(address) end end end diff --git a/lib/super_good/solidus_taxjar/version.rb b/lib/super_good/solidus_taxjar/version.rb index 6d001e4..ac6b87b 100644 --- a/lib/super_good/solidus_taxjar/version.rb +++ b/lib/super_good/solidus_taxjar/version.rb @@ -1,5 +1,5 @@ module SuperGood - module SolidusTaxJar - VERSION = "0.17.1" + module SolidusTaxjar + VERSION = "0.18.0" end end |