avatax_client

Reduce the burden of integration with the Avalara Avatax API. Avatax simplifies the calculation taxes. This project is targeted at their more recent REST API (v2 and up).

Usage

Setup

Configure endpoint and credentials via an initializer:

AvataxClient.configure do |config|
    config.username = ENV["AVALARA_USERNAME"]
    config.password = ENV["AVALARA_PASSWORD"]
    config.version = "v2"
    config.endpoint = ENV["AVALARA_ENDPOINT"] || "https://sandbox-rest.avatax.com"
    config.tax_codes = OpenStruct.new(foo_tax_code: "foo_tax_code")
    config.item_codes = OpenStruct.new(foo_item_code: "foo_item_code")
    # will call `debug_response` before the `response` object is evaluated in `AvataxClient::Request::Base.handle_response`
    config.debug = true

    # useful when you want to view the json in the response for test fixtures, etc.
    config.debug_response = lambda { |response|
      # either use defaults or override here
      # see AvataxClient::Configuration
    }
  end

Creating a Transaction (get taxes)

# see lib/avatax_client/request/transaction.rb and related models for details on the attributes
# attributes is a Hash
transaction = AvataxClient::Request::Transaction.new(attributes)

response_transaction = transaction.create!

# see lib/avatax_client/response/transaction.rb
response_transaction.total_tax

# see lib/avatax_client/response/line_item.rb
response_transaction.lines

# see lib/avatax_client/response/line_item_detail.rb
response_transaction.lines.first.details

Contributing

There are many api calls, models and model attributes to account for. Our team is adding what we need, but we welcome PRs.

Copyright © 2017 Communication Service for the Deaf (CSD www.csd.org). See LICENSE.txt for further details.