Created
June 11, 2013 00:36
-
-
Save joshnuss/5753667 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'avalara' | |
Avalara.username = "[email protected]" | |
Avalara.password = 'pass' | |
Avalara.endpoint = 'https://development.avalara.net' # this is the test url, in production use https://rest.avalara.net | |
invoice = Avalara::Request::Invoice.new(customer_code: '[email protected]') | |
origin = Avalara::Request::Address.new(address_code: 1, line1: '1600 Amphitheatre Pkwy', city: 'Mountain View', region: 'CA', country: 'USA', postal_code: '94043') | |
destination = Avalara::Request::Address.new(address_code: 2, line1: '1 Infinite Loop', city: 'Cupertino', region: 'CA', country: 'USA', postal_code: '95014') | |
line = Avalara::Request::Line.new(line_no: 1, destination_code: 2, origin_code: 1, item_code: 'X123', description: 'T-Shirt', qty: 1, amount: 9.99) | |
invoice.addresses = [origin, destination] | |
invoice.lines = [line] | |
response = Avalara.get_tax(invoice) | |
total_tax = response.tax_lines.inject(0) {|sum, line| sum + line.tax.to_f } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment