Sha256: e90f0be24acf6a3880187598fda24489de8124862552b9e8f902d82d7f67ebba

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

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)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
avatax-22.5.0 example/avatax.rb
avatax-22.3.0 example/avatax.rb
avatax-22.2.1 example/avatax.rb
avatax-22.2.0 example/avatax.rb