Class: Taxbear::Taxjar
- Inherits:
-
Object
- Object
- Taxbear::Taxjar
- Includes:
- HTTParty
- Defined in:
- lib/taxbear/taxjar.rb
Class Method Summary collapse
-
.get_rates_by_zipcode(zipcode) ⇒ Hash
Gets tax rates from TaxJar API based on zipcode.
-
.validate_token(token) ⇒ Boolean
Takes a tokens and returns whether the token is valid.
Class Method Details
.get_rates_by_zipcode(zipcode) ⇒ Hash
Gets tax rates from TaxJar API based on zipcode.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/taxbear/taxjar.rb', line 16 def get_rates_by_zipcode(zipcode) require_api_key() response = get("/rates/#{zipcode}", {headers: auth_header}) if response.success? response.fetch("rate") else raise TaxjarError, "Unable to get tax rates from TaxJar API." end end |
.validate_token(token) ⇒ Boolean
Takes a tokens and returns whether the token is valid.
31 32 33 |
# File 'lib/taxbear/taxjar.rb', line 31 def validate_token(token) get("/categories", headers: auth_header(token)).success? end |