Giter Site home page Giter Site logo

avatax-rest-v2-js-sdk's Introduction

AvaTax Rest V2 Node.js SDK

AvaTax v2 SDK for languages using node.js

Version Build Status Downloads Try on RunKit

Installation

Install the package with:

# using npm 
npm install avatax

# using yarn
yarn add avatax

Usage

Configuration

// es5 import
var Avatax = require('avatax');

// es6/7 import
// import Avatax from 'avatax';

// resolve configuration and credentials
const config = {
  appName: 'your-app',
  appVersion: '1.0',
  environment: 'sandbox',
  machineName: 'your-machine-name'
};

const creds = {
  username: '<your-username>',
  password: '<your-password>'
};

var client = new Avatax(config).withSecurity(creds);

Tax Calculation

const taxDocument = {
  type: 'SalesInvoice',
  companyCode: 'abc123',
  date: '2017-04-12',
  customerCode: 'ABC',
  purchaseOrderNo: '2017-04-12-001',
  addresses: {
    SingleLocation: {
      line1: '123 Main Street',
      city: 'Irvine',
      region: 'CA',
      country: 'US',
      postalCode: '92615'
    }
  },
  lines: [
    {
      number: '1',
      quantity: 1,
      amount: 100,
      taxCode: 'PS081282',
      itemCode: 'Y0001',
      description: 'Yarn'
    }
  ],
  commit: true,
  currencyCode: 'USD',
  description: 'Yarn'
}

return client.createTransaction({ model: taxDocument })
  .then(result => {
    // response tax document
    console.log(result);
  });

Address Validation

const address = {
  city: 'irvine',
  postalCode: '92615',
  region: 'ca',
  country: 'us'
};

return client.resolveAddress(address)
  .then(result => {
    // address validation result
    console.log(result);
  });

SDK Development

Adding integration test credentials

Running integration tests will hit the deployed lower environment

Test credentials are resolved in the following order:

  1. Environment variables

The following environment variables will get loaded as test credentials

SANDBOX_USERNAME="your-username"
SANDBOX_PASSWORD="your-password"
  1. Local credentials file

You can also add a local credentials file to the the path "<project_root>/local_creds.json". This file will be gitignored

{
  "username": "your-username",
  "password": "your-password"
}
  1. Static (mock) values

The mocked values are used for unit tests via 'nock'.

The test credentials helper can be found here https://github.com/avadev/AvaTax-REST-V2-JS-SDK/blob/master/test/helpers/load_creds.js

Publish tags upstream

# assuming a tag of v17.5.2 and a remote of 'upstream'
git push upstream v17.5.2

avatax-rest-v2-js-sdk's People

Contributors

brian-hunter-avalara avatar han8909227 avatar justinsoliz avatar ted-spence-avalara avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.