zip_tax 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in zip_tax.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Eric Steele
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.
@@ -0,0 +1,124 @@
1
+ # ZipTax
2
+
3
+ This is a Ruby wrapper for working with the [Zip-Tax API]('http://www.zip-tax.com/documentation').
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zip_tax'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zip_tax
18
+
19
+ ## Usage
20
+
21
+ ### ZipTax.key
22
+
23
+ Before you do anything, make sure you set your Zip-Tax api key.
24
+
25
+ ```ruby
26
+ ZipTax.key = "123456789" #sets the api key
27
+ ```
28
+
29
+ ### ZipTax.request
30
+
31
+ ```ruby
32
+ ZipTax.request(90210) #returns the raw request, jsonified.
33
+
34
+ => { "version" => "v20",
35
+ "rCode" => 100,
36
+ "results" => [
37
+ { "geoPostalCode" => "90210",
38
+ "geoCity" => "BEVERLY HILLS",
39
+ "geoCounty" => "LOS ANGELES",
40
+ "geoState" => "CA",
41
+ "taxSales" => 0.087499998509884,
42
+ "taxUse" => 0.087499998509884,
43
+ "txbService" => "N",
44
+ "txbFreight" => "N",
45
+ "stateSalesTax" => 0.0625,
46
+ "stateUseTax" => 0.0625,
47
+ "citySalesTax" => 0,
48
+ "cityUseTax" => 0,
49
+ "cityTaxCode" => "",
50
+ "countySalesTax" => 0.0099999997764826,
51
+ "countyUseTax" => 0.0099999997764826,
52
+ "countyTaxCode" => "19",
53
+ "districtSalesTax"=> 0.014999999664724,
54
+ "districtUseTax" => 0.014999999664724 },
55
+ { "geoPostalCode" => "90210",
56
+ "geoCity" => "WESTLAKE",
57
+ "geoCounty" => "LOS ANGELES",
58
+ "geoState" => "CA",
59
+ "taxSales" => 0.087499998509884,
60
+ "taxUse" => 0.087499998509884,
61
+ "txbService" => "N",
62
+ "txbFreight" => "N",
63
+ "stateSalesTax" => 0.0625,
64
+ "stateUseTax" => 0.0625,
65
+ "citySalesTax" => 0,
66
+ "cityUseTax" => 0,
67
+ "cityTaxCode" => "19",
68
+ "countySalesTax" => 0.0099999997764826,
69
+ "countyUseTax" => 0.0099999997764826,
70
+ "countyTaxCode" => "19",
71
+ "districtSalesTax"=> 0.014999999664724,
72
+ "districtUseTax" => 0.014999999664724 }
73
+ ]
74
+ }
75
+ ```
76
+
77
+ ### ZipTax.rate(zip)
78
+
79
+ ```ruby
80
+ ZipTax.rate(90210) #returns the sales tax rate for that zip code
81
+ => 0.087499998509884
82
+ ```
83
+
84
+ ```ruby
85
+ ZipTax.rate(90210, 'CA') #returns the sales tax rate for an item sold in a specific state
86
+ => 0.087499998509884
87
+ ```
88
+
89
+ ```ruby
90
+ ZipTax.rate(90210, 'TX') #returns 0.0 if sales tax isn't neccessary in that state
91
+ => 0.0
92
+ ```
93
+
94
+ ### ZipTax.info(zip)
95
+
96
+ ```ruby
97
+ ZipTax.info(90210) #returns a hash of information about a specified zip code
98
+ => { "geoPostalCode" => "90210",
99
+ "geoCity" => "BEVERLY HILLS",
100
+ "geoCounty" => "LOS ANGELES",
101
+ "geoState" => "CA",
102
+ "taxSales" => 0.087499998509884,
103
+ "taxUse" => 0.087499998509884,
104
+ "txbService" => "N",
105
+ "txbFreight" => "N",
106
+ "stateSalesTax" => 0.0625,
107
+ "stateUseTax" => 0.0625,
108
+ "citySalesTax" => 0,
109
+ "cityUseTax" => 0,
110
+ "cityTaxCode" => "",
111
+ "countySalesTax" => 0.0099999997764826,
112
+ "countyUseTax" => 0.0099999997764826,
113
+ "countyTaxCode" => "19",
114
+ "districtSalesTax"=> 0.014999999664724,
115
+ "districtUseTax" => 0.014999999664724 }
116
+ ```
117
+
118
+ ## Contributing
119
+
120
+ 1. Fork it
121
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
122
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
123
+ 4. Push to the branch (`git push origin my-new-feature`)
124
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,36 @@
1
+ require "zip_tax/version"
2
+ require 'net/http'
3
+ require 'json'
4
+
5
+ module ZipTax
6
+ @@host = 'api.zip-tax.com'
7
+ @@key ||= nil
8
+
9
+ def self.key=(key)
10
+ @@key = key
11
+ end
12
+
13
+ def self.key
14
+ @@key
15
+ end
16
+
17
+ def self.request(zip)
18
+ key = @@key
19
+ host = @@host
20
+ raise ArgumentError, "Zip-Tax API key must be set using ZipTax.key=" if key.nil?
21
+ path = "/request/v20?key=#{key}&postalcode=#{zip}"
22
+ response = JSON.parse(Net::HTTP.get(host, path))
23
+ raise StandardError, "Zip-Tax returned an empty response using the zip code #{zip}" if response["results"].empty?
24
+ return response
25
+ end
26
+
27
+ def self.rate(zip, state = nil)
28
+ response = request(zip)
29
+ state.nil? || state.upcase == response['results'][0]['geoState'] ? response['results'][0]['taxSales'] : 0.0
30
+ end
31
+
32
+ def self.info(zip)
33
+ response = request(zip)
34
+ return response['results'][0]
35
+ end
36
+ end
@@ -0,0 +1,3 @@
1
+ module ZipTax
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'zip_tax/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "zip_tax"
8
+ gem.version = ZipTax::VERSION
9
+ gem.authors = ["Eric Steele"]
10
+ gem.email = ["eric@notvelcro.com"]
11
+ gem.description = %q{Ruby wrapper for the Zip-Tax api}
12
+ gem.summary = %q{This is a Ruby wrapper for interacting with the Zip-Tax API}
13
+ gem.homepage = "https://github.com/genericsteele/zip_tax"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zip_tax
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Eric Steele
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-27 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Ruby wrapper for the Zip-Tax api
15
+ email:
16
+ - eric@notvelcro.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - lib/zip_tax.rb
27
+ - lib/zip_tax/version.rb
28
+ - zip_tax.gemspec
29
+ homepage: https://github.com/genericsteele/zip_tax
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.23
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: This is a Ruby wrapper for interacting with the Zip-Tax API
53
+ test_files: []