taxjar 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +27 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +10 -0
- data/lib/faraday/raise_http_exception.rb +51 -0
- data/lib/taxjar.rb +23 -0
- data/lib/taxjar/client.rb +49 -0
- data/lib/taxjar/configuration.rb +50 -0
- data/lib/taxjar/error.rb +17 -0
- data/lib/taxjar/version.rb +3 -0
- data/taxjar.gemspec +31 -0
- data/test/fixtures/sales_tax.yml +56 -0
- data/test/fixtures/tax_rate.yml +56 -0
- data/test/taxjar/client_test.rb +47 -0
- data/test/taxjar/configuration_test.rb +27 -0
- data/test/taxjar/taxjar_test.rb +7 -0
- data/test/test_helper.rb +10 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9a7f32540b7e3ebf9ea9395b6f8c1222cb41560c
|
4
|
+
data.tar.gz: 0f628c4661506f255eee7ad29be2087e9962b6d6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64b6ad3c367c71885a720656877d4483e9018cc02221253435cf2d710a55f885c3237bcf0072af36ac5e5929d96da0d9975a99a9e0d58aef046ae1c2662ef756
|
7
|
+
data.tar.gz: 2bf57480e160a4bc1378e9a0c8dab12915fa9c3ae50320b93a76359f8e807f79bd812d4c17513a254777772ab68bc945681cc0d1b6555aa23b2b396eeddc4c81
|
data/.gitignore
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.DS_Store
|
4
|
+
.rvmrc
|
5
|
+
.ruby-version
|
6
|
+
.yardoc
|
7
|
+
.rake_tasks~
|
8
|
+
Gemfile.lock
|
9
|
+
coverage/*
|
10
|
+
doc/*
|
11
|
+
log/*
|
12
|
+
pkg/*
|
13
|
+
.idea/*
|
14
|
+
/.bundle/
|
15
|
+
/.yardoc
|
16
|
+
/Gemfile.lock
|
17
|
+
/_yardoc/
|
18
|
+
/coverage/
|
19
|
+
/doc/
|
20
|
+
/pkg/
|
21
|
+
/spec/reports/
|
22
|
+
/tmp/
|
23
|
+
*.bundle
|
24
|
+
*.so
|
25
|
+
*.o
|
26
|
+
*.a
|
27
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Darren Johnson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
# Taxjar
|
2
|
+
|
3
|
+
Taxjar is a Ruby API wrapper for Taxjar's sales tax and tax rate API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'taxjar'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install taxjar
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Please reference the Taxjar [API Documentation](http://www.taxjar.com/api/docs/)
|
24
|
+
|
25
|
+
Configuration:
|
26
|
+
```ruby
|
27
|
+
Taxjar.configure do |config|
|
28
|
+
config.auth_token = "authtokenstring"
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
Sales tax:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
options = {
|
37
|
+
amount: 10,
|
38
|
+
shipping: 2,
|
39
|
+
to_country: "US",
|
40
|
+
to_state: "NJ",
|
41
|
+
to_city: "Freehold",
|
42
|
+
to_zip: "07728",
|
43
|
+
from_country: "US",
|
44
|
+
from_state: "NJ",
|
45
|
+
from_city: "Ramsey",
|
46
|
+
from_zip: "07446"
|
47
|
+
}
|
48
|
+
response = Taxjar.client.sales_tax(options)
|
49
|
+
# => {"amount_to_collect"=>0.84, "rate"=>0.07, "has_nexus"=>true, "freight_taxable"=>true, "tax_source"=>"destination"}
|
50
|
+
```
|
51
|
+
|
52
|
+
Tax rate lookup:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
options = {
|
56
|
+
zip: "07446",
|
57
|
+
city: "Ramsey",
|
58
|
+
country: "US"
|
59
|
+
}
|
60
|
+
response = Taxjar.client.tax_rate(options)
|
61
|
+
# {"location"=>{"state"=>"NJ", "zip"=>"07446", "state_rate"=>"0.07", "city"=>"RAMSEY", "city_rate"=>"0.0", "county"=>"BERGEN", "county_rate"=>"0.0", "combined_district_rate"=>"0.0", "combined_rate"=>"0.07"}}
|
62
|
+
```
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork it ( https://github.com/djohnson/taxjar/fork )
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module FaradayMiddleware
|
4
|
+
|
5
|
+
class RaiseHttpException < Faraday::Middleware
|
6
|
+
def call(env)
|
7
|
+
@app.call(env).on_complete do |response|
|
8
|
+
case response[:status].to_i
|
9
|
+
when 400
|
10
|
+
raise Taxjar::BadRequest, error_message_400(response)
|
11
|
+
when 401
|
12
|
+
raise Taxjar::NotAuthorized, error_message_400(response)
|
13
|
+
when 404
|
14
|
+
raise Taxjar::NotFound, error_message_400(response)
|
15
|
+
when 500
|
16
|
+
raise Taxjar::InternalServerError, error_message_500(response, "Something is technically wrong.")
|
17
|
+
when 504
|
18
|
+
raise Taxjar::GatewayTimeout, error_message_500(response, "504 Gateway Time-out")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(app)
|
24
|
+
super app
|
25
|
+
@parser = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def error_message_400(response)
|
31
|
+
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{response[:status]}#{error_body(response[:body])}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def error_body(body)
|
35
|
+
|
36
|
+
body = ::JSON.parse(body) if not body.nil? and not body.empty? and body.kind_of?(String)
|
37
|
+
|
38
|
+
if body.nil?
|
39
|
+
nil
|
40
|
+
elsif body['meta'] and body['meta']['error_message'] and not body['meta']['error_message'].empty?
|
41
|
+
": #{body['meta']['error_message']}"
|
42
|
+
elsif body['error_message'] and not body['error_message'].empty?
|
43
|
+
": #{body['error_type']}: #{body['error_message']}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def error_message_500(response, body=nil)
|
48
|
+
"#{response[:method].to_s.upcase} #{response[:url].to_s}: #{[response[:status].to_s + ':', body].compact.join(' ')}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/lib/taxjar.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative "taxjar/version"
|
2
|
+
require_relative "taxjar/error"
|
3
|
+
require_relative "taxjar/configuration"
|
4
|
+
require_relative "taxjar/client"
|
5
|
+
|
6
|
+
module Taxjar
|
7
|
+
extend Configuration
|
8
|
+
|
9
|
+
def self.client(options={})
|
10
|
+
Taxjar::Client.new(options)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Delegate to Taxjar::Client
|
14
|
+
def self.method_missing(method, *args, &block)
|
15
|
+
return super unless client.respond_to?(method)
|
16
|
+
client.send(method, *args, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Delegate to Taxjar::Client
|
20
|
+
def self.respond_to?(method, include_all=false)
|
21
|
+
return client.respond_to?(method, include_all) || super
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "faraday"
|
2
|
+
require 'faraday_middleware'
|
3
|
+
Dir[File.expand_path('../../faraday/*.rb', __FILE__)].each{|f| require f}
|
4
|
+
|
5
|
+
module Taxjar
|
6
|
+
class Client
|
7
|
+
|
8
|
+
attr_accessor *Configuration::VALID_CONFIG_KEYS
|
9
|
+
attr_reader :conn
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
options = Taxjar.options.merge(options)
|
13
|
+
|
14
|
+
Configuration::VALID_CONFIG_KEYS.each do |key|
|
15
|
+
send("#{key}=", options[key])
|
16
|
+
end
|
17
|
+
|
18
|
+
setup_conn
|
19
|
+
end
|
20
|
+
|
21
|
+
def sales_tax(options={})
|
22
|
+
response = @conn.get "/sales_tax", options
|
23
|
+
response.body
|
24
|
+
end
|
25
|
+
|
26
|
+
def tax_rate(options={})
|
27
|
+
response = @conn.get "/locations/#{options.delete(:zip)}", options
|
28
|
+
response.body
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def setup_conn
|
34
|
+
options = {
|
35
|
+
:headers => {'Accept' => "application/#{format}; charset=utf-8", 'User-Agent' => user_agent},
|
36
|
+
:proxy => proxy,
|
37
|
+
:url => endpoint,
|
38
|
+
}.merge(connection_options)
|
39
|
+
|
40
|
+
@conn = Faraday::Connection.new(options) do |c|
|
41
|
+
c.token_auth self.auth_token
|
42
|
+
c.use FaradayMiddleware::ParseJson
|
43
|
+
c.use FaradayMiddleware::RaiseHttpException
|
44
|
+
c.adapter(adapter)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require "faraday"
|
2
|
+
|
3
|
+
module Taxjar
|
4
|
+
module Configuration
|
5
|
+
VALID_CONFIG_KEYS = [
|
6
|
+
:adapter,
|
7
|
+
:auth_token,
|
8
|
+
:endpoint,
|
9
|
+
:format,
|
10
|
+
:proxy,
|
11
|
+
:user_agent,
|
12
|
+
:connection_options ]
|
13
|
+
|
14
|
+
DEFAULT_ADAPTER = Faraday.default_adapter
|
15
|
+
DEFAULT_AUTH_TOKEN = "dae79dc5154ccabd7cb169f616d605e7"
|
16
|
+
DEFAULT_ENDPOINT = "https://api.taxjar.com".freeze
|
17
|
+
DEFAULT_FORMAT = :json
|
18
|
+
DEFAULT_PROXY = nil
|
19
|
+
DEFAULT_USER_AGENT = "Taxjar ruby Gem #{Taxjar::VERSION}".freeze
|
20
|
+
|
21
|
+
DEFAULT_CONNECTION_OPTIONS = {}
|
22
|
+
|
23
|
+
attr_accessor *VALID_CONFIG_KEYS
|
24
|
+
|
25
|
+
def self.extended(base)
|
26
|
+
base.reset
|
27
|
+
end
|
28
|
+
|
29
|
+
def configure
|
30
|
+
yield self
|
31
|
+
end
|
32
|
+
|
33
|
+
def options
|
34
|
+
VALID_CONFIG_KEYS.inject({}) do |option, key|
|
35
|
+
option.merge!(key => send(key))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset
|
40
|
+
self.adapter = DEFAULT_ADAPTER
|
41
|
+
self.endpoint = DEFAULT_ENDPOINT
|
42
|
+
self.auth_token = DEFAULT_AUTH_TOKEN
|
43
|
+
self.format = DEFAULT_FORMAT
|
44
|
+
self.proxy = DEFAULT_PROXY
|
45
|
+
self.user_agent = DEFAULT_USER_AGENT
|
46
|
+
self.connection_options = DEFAULT_CONNECTION_OPTIONS
|
47
|
+
end
|
48
|
+
|
49
|
+
end # Configuration
|
50
|
+
end
|
data/lib/taxjar/error.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Taxjar
|
2
|
+
# Custom error class for rescuing from all Taxjar errors
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
# Raised when Taxjar returns the HTTP status code 400
|
6
|
+
class BadRequest < Error; end
|
7
|
+
|
8
|
+
# Raised when Taxjar returns the HTTP status code 401
|
9
|
+
class NotAuthorized < Error; end
|
10
|
+
|
11
|
+
# Raised when Taxjar returns the HTTP status code 404
|
12
|
+
class NotFound < Error; end
|
13
|
+
|
14
|
+
# Raised when Taxjar returns the HTTP status code 500
|
15
|
+
class InternalServerError < Error; end
|
16
|
+
|
17
|
+
end
|
data/taxjar.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'taxjar/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "taxjar"
|
8
|
+
spec.version = Taxjar::VERSION
|
9
|
+
spec.authors = ["Darren Johnson"]
|
10
|
+
spec.email = ["darrenbjohnson@gmail.com"]
|
11
|
+
spec.summary = %q{A Ruby wrapper for the Taxjar API}
|
12
|
+
spec.description = %q{A Ruby wrapper for the Taxjar API's sales tax and tax rate endpoints}
|
13
|
+
spec.homepage = "http://github.com/djohnson/taxjar"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
spec.add_development_dependency 'vcr', '~> 2.9', '>= 2.9.0'
|
25
|
+
spec.add_development_dependency 'webmock', '~> 1.20', '>= 1.20.0'
|
26
|
+
|
27
|
+
spec.add_runtime_dependency "faraday", ['>= 0.7', '< 0.10']
|
28
|
+
spec.add_runtime_dependency "faraday_middleware", ['>= 0.8', '< 0.10']
|
29
|
+
spec.add_runtime_dependency "multi_json", ">= 1.0.3", "~> 1.0"
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.taxjar.com/sales_tax?amount=10&from_city=Ramsey&from_country=US&from_state=NJ&from_zip=07446&shipping=2&to_city=Freehold&to_country=US&to_state=NJ&to_zip=07728
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Authorization:
|
13
|
+
- Token token="dae79dc5154ccabd7cb169f616d605e7"
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- Cowboy
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Date:
|
28
|
+
- Tue, 30 Dec 2014 19:59:20 GMT
|
29
|
+
Status:
|
30
|
+
- 200 OK
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
X-Xss-Protection:
|
34
|
+
- 1; mode=block
|
35
|
+
X-Content-Type-Options:
|
36
|
+
- nosniff
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- chrome=1
|
39
|
+
Content-Type:
|
40
|
+
- application/json; charset=utf-8
|
41
|
+
Etag:
|
42
|
+
- '"a9ea7272ca4facfde21f8e196a21790a"'
|
43
|
+
Cache-Control:
|
44
|
+
- max-age=0, private, must-revalidate
|
45
|
+
X-Request-Id:
|
46
|
+
- 49407c82-e7a6-4c7e-a1fa-3c0761c4ce42
|
47
|
+
X-Runtime:
|
48
|
+
- '0.023674'
|
49
|
+
Via:
|
50
|
+
- 1.1 vegur
|
51
|
+
body:
|
52
|
+
encoding: UTF-8
|
53
|
+
string: '{"amount_to_collect":0.84,"rate":0.07,"has_nexus":true,"freight_taxable":true,"tax_source":"destination"}'
|
54
|
+
http_version:
|
55
|
+
recorded_at: Tue, 30 Dec 2014 19:59:20 GMT
|
56
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,56 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.taxjar.com/locations/07446?city=Ramsey&country=US
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
User-Agent:
|
11
|
+
- Faraday v0.9.0
|
12
|
+
Authorization:
|
13
|
+
- Token token="dae79dc5154ccabd7cb169f616d605e7"
|
14
|
+
Accept-Encoding:
|
15
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
16
|
+
Accept:
|
17
|
+
- "*/*"
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Server:
|
24
|
+
- Cowboy
|
25
|
+
Connection:
|
26
|
+
- close
|
27
|
+
Date:
|
28
|
+
- Tue, 30 Dec 2014 20:42:38 GMT
|
29
|
+
Status:
|
30
|
+
- 200 OK
|
31
|
+
X-Frame-Options:
|
32
|
+
- SAMEORIGIN
|
33
|
+
X-Xss-Protection:
|
34
|
+
- 1; mode=block
|
35
|
+
X-Content-Type-Options:
|
36
|
+
- nosniff
|
37
|
+
X-Ua-Compatible:
|
38
|
+
- chrome=1
|
39
|
+
Content-Type:
|
40
|
+
- application/json; charset=utf-8
|
41
|
+
Etag:
|
42
|
+
- '"4c698edaabe3530060a6a8280016359a"'
|
43
|
+
Cache-Control:
|
44
|
+
- max-age=0, private, must-revalidate
|
45
|
+
X-Request-Id:
|
46
|
+
- de103f0f-274a-4d4a-b064-6c58faa5adc5
|
47
|
+
X-Runtime:
|
48
|
+
- '0.012139'
|
49
|
+
Via:
|
50
|
+
- 1.1 vegur
|
51
|
+
body:
|
52
|
+
encoding: UTF-8
|
53
|
+
string: '{"location":{"state":"NJ","zip":"07446","state_rate":"0.07","city":"RAMSEY","city_rate":"0.0","county":"BERGEN","county_rate":"0.0","combined_district_rate":"0.0","combined_rate":"0.07"}}'
|
54
|
+
http_version:
|
55
|
+
recorded_at: Tue, 30 Dec 2014 20:42:38 GMT
|
56
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
describe Taxjar::Client do
|
4
|
+
|
5
|
+
describe ".sales_tax" do
|
6
|
+
before do
|
7
|
+
@options = {
|
8
|
+
amount: 10,
|
9
|
+
shipping: 2,
|
10
|
+
to_country: "US",
|
11
|
+
to_state: "NJ",
|
12
|
+
to_city: "Freehold",
|
13
|
+
to_zip: "07728",
|
14
|
+
from_country: "US",
|
15
|
+
from_state: "NJ",
|
16
|
+
from_city: "Ramsey",
|
17
|
+
from_zip: "07446"
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return a SalesTax" do
|
22
|
+
VCR.use_cassette("sales_tax") do
|
23
|
+
response = Taxjar::Client.new.sales_tax(@options)
|
24
|
+
response.must_be :hash
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".tax_rate" do
|
30
|
+
before do
|
31
|
+
@options = {
|
32
|
+
zip: "07446",
|
33
|
+
city: "Ramsey",
|
34
|
+
country: "US"
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return a TaxRate" do
|
39
|
+
VCR.use_cassette("tax_rate") do
|
40
|
+
response = Taxjar::Client.new.tax_rate(@options)
|
41
|
+
response.must_be :hash
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "./test/test_helper"
|
2
|
+
|
3
|
+
describe "configuration" do
|
4
|
+
|
5
|
+
after do
|
6
|
+
Taxjar.reset
|
7
|
+
end
|
8
|
+
|
9
|
+
Taxjar::Configuration::VALID_CONFIG_KEYS.each do |key|
|
10
|
+
describe ".#{key}" do
|
11
|
+
it "should return the default value" do
|
12
|
+
Taxjar.send(key).must_equal Taxjar::Configuration.const_get("DEFAULT_#{key.upcase}")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".configure" do
|
18
|
+
Taxjar::Configuration::VALID_CONFIG_KEYS.each do |key|
|
19
|
+
it "should set the #{key}" do
|
20
|
+
Taxjar.configure do |config|
|
21
|
+
config.send("#{key}=", key)
|
22
|
+
Taxjar.send(key).must_equal key
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: taxjar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Darren Johnson
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: vcr
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.9'
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.9.0
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - "~>"
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2.9'
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 2.9.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: webmock
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.20'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.20.0
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.20'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.20.0
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: faraday
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.7'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.10'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.7'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0.10'
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: faraday_middleware
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0.8'
|
122
|
+
- - "<"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
type: :runtime
|
126
|
+
prerelease: false
|
127
|
+
version_requirements: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.8'
|
132
|
+
- - "<"
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0.10'
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: multi_json
|
137
|
+
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: 1.0.3
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '1.0'
|
145
|
+
type: :runtime
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.0.3
|
152
|
+
- - "~>"
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '1.0'
|
155
|
+
description: A Ruby wrapper for the Taxjar API's sales tax and tax rate endpoints
|
156
|
+
email:
|
157
|
+
- darrenbjohnson@gmail.com
|
158
|
+
executables: []
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- ".gitignore"
|
163
|
+
- Gemfile
|
164
|
+
- LICENSE.txt
|
165
|
+
- README.md
|
166
|
+
- Rakefile
|
167
|
+
- lib/faraday/raise_http_exception.rb
|
168
|
+
- lib/taxjar.rb
|
169
|
+
- lib/taxjar/client.rb
|
170
|
+
- lib/taxjar/configuration.rb
|
171
|
+
- lib/taxjar/error.rb
|
172
|
+
- lib/taxjar/version.rb
|
173
|
+
- taxjar.gemspec
|
174
|
+
- test/fixtures/sales_tax.yml
|
175
|
+
- test/fixtures/tax_rate.yml
|
176
|
+
- test/taxjar/client_test.rb
|
177
|
+
- test/taxjar/configuration_test.rb
|
178
|
+
- test/taxjar/taxjar_test.rb
|
179
|
+
- test/test_helper.rb
|
180
|
+
homepage: http://github.com/djohnson/taxjar
|
181
|
+
licenses:
|
182
|
+
- MIT
|
183
|
+
metadata: {}
|
184
|
+
post_install_message:
|
185
|
+
rdoc_options: []
|
186
|
+
require_paths:
|
187
|
+
- lib
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
189
|
+
requirements:
|
190
|
+
- - ">="
|
191
|
+
- !ruby/object:Gem::Version
|
192
|
+
version: '0'
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - ">="
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
requirements: []
|
199
|
+
rubyforge_project:
|
200
|
+
rubygems_version: 2.4.3
|
201
|
+
signing_key:
|
202
|
+
specification_version: 4
|
203
|
+
summary: A Ruby wrapper for the Taxjar API
|
204
|
+
test_files:
|
205
|
+
- test/fixtures/sales_tax.yml
|
206
|
+
- test/fixtures/tax_rate.yml
|
207
|
+
- test/taxjar/client_test.rb
|
208
|
+
- test/taxjar/configuration_test.rb
|
209
|
+
- test/taxjar/taxjar_test.rb
|
210
|
+
- test/test_helper.rb
|