Sha256: 6f46c1bc6a0a4a72f3b5b8b12f2cd1a83da0b6c94fe4cb2e4b0536516b6a9cb7
Contents?: true
Size: 963 Bytes
Versions: 3
Compression:
Stored size: 963 Bytes
Contents
require 'json' require 'net/http' require 'addressable/uri' require 'base64' require_relative 'configuration' class AvaTax::AddressService @@service_path = '/1.0/address/' attr_accessor :account_number, :license_key, :service_url def initialize() @account_number = AvaTax::Configuration.instance.account_number @license_key = AvaTax::Configuration.instance.license_key @service_url = AvaTax::Configuration.instance.service_url end def validate(address) return address if address.nil? encodedquery = Addressable::URI.new encodedquery.query_values = address uri = URI(@service_url + @@service_path + "validate?"+ encodedquery.query) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER cred = 'Basic '+ Base64.encode64(@account_number + ":"+ @license_key) res = http.get(uri.request_uri, 'Authorization' => cred) JSON.parse(res.body) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
avatax-14.4.4 | lib/avatax/address_service.rb |
avatax-14.4.3 | lib/avatax/address_service.rb |
avatax-14.4.2 | lib/avatax/address_service.rb |