Class: SuperGood::SolidusTaxjar::Addresses
- Inherits:
-
Object
- Object
- SuperGood::SolidusTaxjar::Addresses
- Defined in:
- lib/super_good/solidus_taxjar/addresses.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(api: ::SuperGood::SolidusTaxjar.api) ⇒ Addresses
constructor
A new instance of Addresses.
- #normalize(spree_address) ⇒ Object
- #possibilities(spree_address) ⇒ Object
Constructor Details
#initialize(api: ::SuperGood::SolidusTaxjar.api) ⇒ Addresses
Returns a new instance of Addresses.
14 15 16 |
# File 'lib/super_good/solidus_taxjar/addresses.rb', line 14 def initialize(api: ::SuperGood::SolidusTaxjar.api) @api = api end |
Class Method Details
.normalize(spree_address) ⇒ Object
5 6 7 |
# File 'lib/super_good/solidus_taxjar/addresses.rb', line 5 def normalize(spree_address) new.normalize(spree_address) end |
.possibilities(spree_address) ⇒ Object
9 10 11 |
# File 'lib/super_good/solidus_taxjar/addresses.rb', line 9 def possibilities(spree_address) new.possibilities(spree_address) end |
Instance Method Details
#normalize(spree_address) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/super_good/solidus_taxjar/addresses.rb', line 18 def normalize(spree_address) taxjar_address = taxjar_addresses(spree_address).first return if taxjar_address.nil? ::Spree::Address.immutable_merge(spree_address, { country: us, # TaxJar only supports the US currently. state: state(taxjar_address.state), zipcode: taxjar_address.zip, city: taxjar_address.city, address1: taxjar_address.street }) end |
#possibilities(spree_address) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/super_good/solidus_taxjar/addresses.rb', line 32 def possibilities(spree_address) taxjar_addresses(spree_address).map { |taxjar_address| ::Spree::Address.immutable_merge(spree_address, { country: us, # TaxJar only supports the US currently. state: state(taxjar_address.state), zipcode: taxjar_address.zip, city: taxjar_address.city, address1: taxjar_address.street }) } end |