-
Notifications
You must be signed in to change notification settings - Fork 56
/
avatax.rb
47 lines (42 loc) · 1.27 KB
/
avatax.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require 'yaml'
require File.expand_path('../../lib/avatax', __FILE__)
credentials = YAML.load_file(File.expand_path('../credentials.yaml', __FILE__))
AvaTax.configure do |config|
begin
credentials = YAML.load_file(File.expand_path('../credentials.yaml', __FILE__))
config.endpoint = credentials['endpoint']
config.username = credentials['username']
config.password = credentials['password']
rescue
config.endpoint = 'https://sandbox-rest.avatax.com'
config.username = ENV['SANDBOX_USERNAME']
config.password = ENV['SANDBOX_PASSWORD']
end
end
@client = AvaTax::Client.new(:logger => true)
# puts @client.query_companies
createTransactionModel = {
"type" => 'SalesInvoice',
"companyCode" => '12670',
"date" => '2017-06-05',
"customerCode" => 'ABC',
"addresses" => {
"ShipFrom" => {
"line1" => "123 Main Street",
"city" => "Irvine",
"region" => "CA",
"country" => "US",
"postalCode" => "92615"
},
"ShipTo" => {
"line1" => "100 Market Street",
"city" => "San Francisco",
"region" => "CA",
"country" => "US",
"postalCode" => "94105"
}
},
"lines" => [ { "amount" => 100 }]
}
transaction = @client.create_transaction(createTransactionModel)
puts JSON.pretty_generate(transaction)