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.
- Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
- Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
- Fork the project.
- Start a feature/bugfix branch.
- Commit and push until you are happy with your contribution.
- Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
- Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
Copyright
Copyright (c) 2017 Communication Service for the Deaf (CSD www.csd.org). See LICENSE.txt for further details.