# Refactoring your integration using AvaTax SDKs

Source: https://developer.avalara.com/soap-to-restv2-refactor-guide/iqz3372473226311/

# Refactoring your integration using AvaTax SDKs

Learn how to refactor your integration using AvaTax SDKs, including REST and SOAP examples.var transaction = client.CreateTransaction(null, createModel);

This section describes how to refactor your integration using the SDKs.

Note

-   REST SDKs are generated against the entire AvaTax Swagger API repository and have corresponding methods and models for everything you can do directly with the AvaTax API.
-   REST SDKs expose a TransactionBuilder model for calling for a tax calculation example.

Language

Legacy SOAP SDK

REST-based SDK

Other notes

C++

[https://github.com/avadev/AvaTax-Calc-SOAP-CPP](https://github.com/avadev/AvaTax-Calc-SOAP-CPP)

[https://developer.avalara.com/sdk/csharp/](https://developer.avalara.com/sdk/csharp/)

The C++ uses legacy C# DLL version 14.4.1, which may not work as expected with TLS 1.2-only enabled endpoints.

Javascript

[https://github.com/Matter-and-Form/node-avatax](https://github.com/Matter-and-Form/node-avatax)

[https://developer.avalara.com/sdk/javascript/](https://developer.avalara.com/sdk/javascript/)

Perl

[https://github.com/mjgardner/WebService-Avalara-AvaTax](https://github.com/mjgardner/WebService-Avalara-AvaTax)

N/A

Contact [Avalara Support](https://help.avalara.com/Contact_Avalara)

PHP

[https://github.com/avadev/AvaTax-SOAP-PHP-SDK](https://github.com/avadev/AvaTax-SOAP-PHP-SDK)

[https://developer.avalara.com/sdk/php/](https://developer.avalara.com/sdk/php/)

Python

[https://github.com/avadev/AvaTax-Calc-REST-PythonPython](https://github.com/avadev/AvaTax-Calc-REST-Python)

[https://developer.avalara.com/sdk/python/](https://developer.avalara.com/sdk/python/)

SalesForceApex

[SalesForceApex](https://github.com/avadev/AvaTax-SOAP-SF-SDK)

N/A

Contact [Avalara Support](https://help.avalara.com/Contact_Avalara)

## C# examples

This section shows examples of making SOAP calls using C# in SOAP and in RESTv2.

## Setup call to AvaTax

**SOAP**

```
TaxSvc taxSvc = new TaxSvc();
taxSvc.Configuration.Security.Account = ConfigurationManager.AppSettings["Account"];
taxSvc.Configuration.Url = ConfigurationManager.AppSettings["URL"];
taxSvc.Configuration.Url = ConfigurationManager.AppSettings["URL"];
taxSvc.Profile.Client = "myApp";
taxSvc.Configuration.Security.Account = ConfigurationManager.AppSettings["Account"];
tokenKey = Util.Returnpassword();
taxSvc.Configuration.Security.License = tokenKey;
```

**REST V2**

```
var client = new AvaTaxClient("myApp", "myApp version 1.0", Environment.MachineName, AvaTaxEnvironment.Sandbox)
.WithSecurity("your basic auth username or account", "your basic auth password or key ");
```

## Build tax calculation request

**SOAP**

```
GetTaxRequest getTaxRequest = new GetTaxRequest();
getTaxRequest.CustomerCode = "Guest";
getTaxRequest.DocDate = DateTime.Now;
getTaxRequest.DocCode = "INV49990";
getTaxRequest.DetailLevel = DetailLevel.Tax;
getTaxRequest.DocType = DocumentType.SalesInvoice;Address address1 = new Address();
address1.Line1 = "45 Fremont Street";
address1.City = "San Francisco";
address1.Region = "CA";Line line1 = new Line();
line1.No = "01";
line1.Qty = 1;
line1.Amount = 40.21;line1.TaxCode = “PC040400”
line1.OriginAddress = address1;
line1.DestinationAddress = address1; getTaxRequest.Lines.Add(line1);
```

**REST V2**

```
var createModel = new CreateTransactionModel()
{
  type = DocumentType.SalesInvoice,
  code = "IN49990",
  companyCode = "Default",
  date = DateTime.Today,
  customerCode = "Guest",
  lines = new List()
  {        
    new LineItemModel()
    {            
      number = "1",
      quantity = 1,
      amount = 40.21m,
      taxCode = "PC040400"
    }
  },
  addresses = new AddressesModel()
  {
    singleLocation = new AddressLocationInfo()
    {
      line1 = "2000 Main Street",
      city = "Irvine",
      region = "CA",
      country = "US",
      postalCode = "92614" 
    }
  }
};
```

## Initiate tax request

**SOAP**

```
GetTaxResult getTaxResult = taxSvc.GetTax(getTaxRequest);
```

**REST V2**

```
var transaction = client.CreateTransaction(null, createModel);
```