From 054a25e9da909242fef25770c31678c251621573 Mon Sep 17 00:00:00 2001 From: Jared Norman Date: Wed, 30 Jan 2019 13:14:58 -0800 Subject: Extract address lookup params as well --- lib/super_good/solidus_taxjar/api.rb | 8 +------- lib/super_good/solidus_taxjar/api_params.rb | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/super_good') diff --git a/lib/super_good/solidus_taxjar/api.rb b/lib/super_good/solidus_taxjar/api.rb index 1392a47..d52a4a4 100644 --- a/lib/super_good/solidus_taxjar/api.rb +++ b/lib/super_good/solidus_taxjar/api.rb @@ -17,13 +17,7 @@ module SuperGood end def tax_rates_for(address) - taxjar_client.rates_for_location( - address.zipcode, - street: address.address1, - city: address.city, - state: address&.state&.abbr || address.state_name, - country: address.country.iso - ) + taxjar_client.rates_for_location(*APIParams.address_params(address)) end private diff --git a/lib/super_good/solidus_taxjar/api_params.rb b/lib/super_good/solidus_taxjar/api_params.rb index eba0947..4e61253 100644 --- a/lib/super_good/solidus_taxjar/api_params.rb +++ b/lib/super_good/solidus_taxjar/api_params.rb @@ -4,14 +4,26 @@ module SuperGood class << self def order_params(order) {} - .merge(address_params(order.tax_address)) + .merge(order_address_params(order.tax_address)) .merge(line_items_params(order.line_items)) .merge(shipping: order.shipment_total) end + def address_params(address) + [ + address.zipcode, + { + street: address.address1, + city: address.city, + state: address&.state&.abbr || address.state_name, + country: address.country.iso + } + ] + end + private - def address_params(address) + def order_address_params(address) { to_country: address.country.iso, to_zip: address.zipcode, -- cgit v1.2.3