Sha256: 28564353c7a996c202b8b2ba510d3f2e3e8523f51334b5830bf1eea80541dbbc
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module ActiveTax module States class WA API_URI = "http://dor.wa.gov/AddressRates.aspx" def self.rate(address={}) # http://dor.wa.gov/AddressRates.aspx?output=text&addr=6500%20Linderson%20way&city=&zip=98501 params = { output: "text", addr: "#{address[:address]}", city: "#{address[:city]}", zip: "#{address[:zip]}" } require 'net/http' # Needed for HTTP requests uri = URI("#{API_URI}") uri.query = URI.encode_www_form(params) res = Net::HTTP.get_response(uri) # LocationCode=3406 Rate=0.087 ResultCode=0 if res.is_a?(Net::HTTPSuccess) result = self.parse_result(res.body) return result["Rate"].to_f else return false end end def self.parse_result(text) r = {} items = text.split(" ") items.each do |item| k, v = item.split("=") r[k] = v end r end end WASHINGTON = WA unless defined?(WASHINGTON) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
active_tax-0.2.0 | lib/active_tax/states/wa.rb |