Categorygithub.com/stripedapps/avalara-go-sdk
repositorypackage
0.0.0-20240314131226-193a1dd346fc
Repository: https://github.com/stripedapps/avalara-go-sdk.git
Documentation: pkg.go.dev

# README

Go API client for openapi

REST interface to Avalara's enterprise tax service, AvaTax.

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: v2
  • Package version: 1.0.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen For more information, please visit https://developer.avalara.com

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import openapi "github.com/stripedapps/avalara-go-sdk"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value sw.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), openapi.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), openapi.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices and sw.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), openapi.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), openapi.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to https://rest-sbx-preview.avalara.net

ClassMethodHTTP requestDescription
AccountsAPIApiV2AccountsByIdDeleteDelete /api/v2/accounts/{id}Delete a single account
AccountsAPIApiV2AccountsByIdGetGet /api/v2/accounts/{id}Retrieve a single account
AccountsAPIApiV2AccountsByIdPutPut /api/v2/accounts/{id}Update a single account
AccountsAPIApiV2AccountsGetGet /api/v2/accountsRetrieve all accounts
AccountsAPIApiV2AccountsPostPost /api/v2/accountsCreate a new account
AddressesAPIApiV2AddressesResolvePostPost /api/v2/addresses/resolveRetrieve geolocation information for a specified address
BatchesAPIApiV2BatchesGetGet /api/v2/batchesRetrieve all batches
BatchesAPIApiV2CompaniesByCompanyIdBatchesByIdDeleteDelete /api/v2/companies/{companyId}/batches/{id}Delete a single batch
BatchesAPIApiV2CompaniesByCompanyIdBatchesByIdGetGet /api/v2/companies/{companyId}/batches/{id}Retrieve a single batch
BatchesAPIApiV2CompaniesByCompanyIdBatchesByIdPutPut /api/v2/companies/{companyId}/batches/{id}Update a single batch
BatchesAPIApiV2CompaniesByCompanyIdBatchesGetGet /api/v2/companies/{companyId}/batchesRetrieve all batches for this company
BatchesAPIApiV2CompaniesByCompanyIdBatchesPostPost /api/v2/companies/{companyId}/batchesCreate a new batch
CompaniesAPIApiV2CompaniesByIdDeleteDelete /api/v2/companies/{id}Delete a single company
CompaniesAPIApiV2CompaniesByIdGetGet /api/v2/companies/{id}Retrieve a single company
CompaniesAPIApiV2CompaniesByIdPutPut /api/v2/companies/{id}Update a single company
CompaniesAPIApiV2CompaniesGetGet /api/v2/companiesRetrieve all companies
CompaniesAPIApiV2CompaniesInitializePostPost /api/v2/companies/initializeQuick setup for a company with a single physical address
CompaniesAPIApiV2CompaniesPostPost /api/v2/companiesCreate a new company
ContactsAPIApiV2CompaniesByCompanyIdContactsByIdDeleteDelete /api/v2/companies/{companyId}/contacts/{id}Delete a single contact
ContactsAPIApiV2CompaniesByCompanyIdContactsByIdGetGet /api/v2/companies/{companyId}/contacts/{id}Retrieve a single contact
ContactsAPIApiV2CompaniesByCompanyIdContactsByIdPutPut /api/v2/companies/{companyId}/contacts/{id}Update a single contact
ContactsAPIApiV2CompaniesByCompanyIdContactsGetGet /api/v2/companies/{companyId}/contactsRetrieve contacts for this company
ContactsAPIApiV2CompaniesByCompanyIdContactsPostPost /api/v2/companies/{companyId}/contactsCreate a new contact
ContactsAPIApiV2ContactsGetGet /api/v2/contactsRetrieve all contacts
DefinitionsAPIApiV2DefinitionsNexusByCountryByRegionGetGet /api/v2/definitions/nexus/{country}/{region}Retrieve the full list of Avalara-supported nexus for a country and region.
DefinitionsAPIApiV2DefinitionsNexusByCountryGetGet /api/v2/definitions/nexus/{country}Retrieve the full list of Avalara-supported nexus for a country.
DefinitionsAPIApiV2DefinitionsNexusGetGet /api/v2/definitions/nexusRetrieve the full list of Avalara-supported nexus for all countries and regions.
DefinitionsAPIApiV2DefinitionsSubscriptiontypesGetGet /api/v2/definitions/subscriptiontypesRetrieve the full list of Avalara-supported subscription types
DefinitionsAPIApiV2DefinitionsTaxauthoritiesGetGet /api/v2/definitions/taxauthoritiesRetrieve the full list of Avalara-supported tax authorities.
DefinitionsAPIApiV2DefinitionsTaxauthorityformsGetGet /api/v2/definitions/taxauthorityformsRetrieve the full list of Avalara-supported tax authorities.
DefinitionsAPIApiV2DefinitionsTaxcodesGetGet /api/v2/definitions/taxcodesRetrieve the full list of Avalara-supported tax codes.
FilingCalendarsAPIApiV2CompaniesByCompanyIdFilingcalendarsByIdDeleteDelete /api/v2/companies/{companyId}/filingcalendars/{id}Delete a single filing calendar
FilingCalendarsAPIApiV2CompaniesByCompanyIdFilingcalendarsByIdGetGet /api/v2/companies/{companyId}/filingcalendars/{id}Retrieve a single filing calendar
FilingCalendarsAPIApiV2CompaniesByCompanyIdFilingcalendarsByIdPutPut /api/v2/companies/{companyId}/filingcalendars/{id}Update a single filing calendar
FilingCalendarsAPIApiV2CompaniesByCompanyIdFilingcalendarsGetGet /api/v2/companies/{companyId}/filingcalendarsRetrieve filing calendars for this company
FilingCalendarsAPIApiV2CompaniesByCompanyIdFilingcalendarsPostPost /api/v2/companies/{companyId}/filingcalendarsCreate a new filing calendar
FilingCalendarsAPIApiV2FilingcalendarsGetGet /api/v2/filingcalendarsRetrieve all filing calendars
ItemsAPIApiV2CompaniesByCompanyIdItemsByIdDeleteDelete /api/v2/companies/{companyId}/items/{id}Delete a single item
ItemsAPIApiV2CompaniesByCompanyIdItemsByIdGetGet /api/v2/companies/{companyId}/items/{id}Retrieve a single item
ItemsAPIApiV2CompaniesByCompanyIdItemsByIdPutPut /api/v2/companies/{companyId}/items/{id}Update a single item
ItemsAPIApiV2CompaniesByCompanyIdItemsGetGet /api/v2/companies/{companyId}/itemsRetrieve items for this company
ItemsAPIApiV2CompaniesByCompanyIdItemsPostPost /api/v2/companies/{companyId}/itemsCreate a new item
ItemsAPIApiV2ItemsGetGet /api/v2/itemsRetrieve all items
LocationsAPIApiV2CompaniesByCompanyIdLocationsByIdDeleteDelete /api/v2/companies/{companyId}/locations/{id}Delete a single location
LocationsAPIApiV2CompaniesByCompanyIdLocationsByIdGetGet /api/v2/companies/{companyId}/locations/{id}Retrieve a single location
LocationsAPIApiV2CompaniesByCompanyIdLocationsByIdPutPut /api/v2/companies/{companyId}/locations/{id}Update a single location
LocationsAPIApiV2CompaniesByCompanyIdLocationsGetGet /api/v2/companies/{companyId}/locationsRetrieve locations for this company
LocationsAPIApiV2CompaniesByCompanyIdLocationsPostPost /api/v2/companies/{companyId}/locationsCreate a new location
LocationsAPIApiV2LocationsGetGet /api/v2/locationsRetrieve all locations
NexusAPIApiV2CompaniesByCompanyIdNexusByIdDeleteDelete /api/v2/companies/{companyId}/nexus/{id}Delete a single nexus
NexusAPIApiV2CompaniesByCompanyIdNexusByIdGetGet /api/v2/companies/{companyId}/nexus/{id}Retrieve a single nexus
NexusAPIApiV2CompaniesByCompanyIdNexusByIdPutPut /api/v2/companies/{companyId}/nexus/{id}Update a single nexus
NexusAPIApiV2CompaniesByCompanyIdNexusGetGet /api/v2/companies/{companyId}/nexusRetrieve nexus for this company
NexusAPIApiV2CompaniesByCompanyIdNexusPostPost /api/v2/companies/{companyId}/nexusCreate a new nexus
NexusAPIApiV2NexusGetGet /api/v2/nexusRetrieve all nexus
PasswordsAPIApiV2PasswordsPutPut /api/v2/passwordsChange Password
SettingsAPIApiV2CompaniesByCompanyIdSettingsByIdDeleteDelete /api/v2/companies/{companyId}/settings/{id}Delete a single setting
SettingsAPIApiV2CompaniesByCompanyIdSettingsByIdGetGet /api/v2/companies/{companyId}/settings/{id}Retrieve a single setting
SettingsAPIApiV2CompaniesByCompanyIdSettingsByIdPutPut /api/v2/companies/{companyId}/settings/{id}Update a single setting
SettingsAPIApiV2CompaniesByCompanyIdSettingsGetGet /api/v2/companies/{companyId}/settingsRetrieve all settings for this company
SettingsAPIApiV2CompaniesByCompanyIdSettingsPostPost /api/v2/companies/{companyId}/settingsCreate a new setting
SettingsAPIApiV2SettingsGetGet /api/v2/settingsRetrieve all settings
SubscriptionsAPIApiV2AccountsByAccountIdSubscriptionsByIdDeleteDelete /api/v2/accounts/{accountId}/subscriptions/{id}Delete a single subscription
SubscriptionsAPIApiV2AccountsByAccountIdSubscriptionsByIdGetGet /api/v2/accounts/{accountId}/subscriptions/{id}Retrieve a single subscription
SubscriptionsAPIApiV2AccountsByAccountIdSubscriptionsByIdPutPut /api/v2/accounts/{accountId}/subscriptions/{id}Update a single subscription
SubscriptionsAPIApiV2AccountsByAccountIdSubscriptionsGetGet /api/v2/accounts/{accountId}/subscriptionsRetrieve subscriptions for this account
SubscriptionsAPIApiV2AccountsByAccountIdSubscriptionsPostPost /api/v2/accounts/{accountId}/subscriptionsCreate a new subscription
SubscriptionsAPIApiV2SubscriptionsGetGet /api/v2/subscriptionsRetrieve all subscriptions
TaxCodesAPIApiV2CompaniesByCompanyIdTaxcodesByIdDeleteDelete /api/v2/companies/{companyId}/taxcodes/{id}Delete a single tax code
TaxCodesAPIApiV2CompaniesByCompanyIdTaxcodesByIdGetGet /api/v2/companies/{companyId}/taxcodes/{id}Retrieve a single tax code
TaxCodesAPIApiV2CompaniesByCompanyIdTaxcodesByIdPutPut /api/v2/companies/{companyId}/taxcodes/{id}Update a single tax code
TaxCodesAPIApiV2CompaniesByCompanyIdTaxcodesGetGet /api/v2/companies/{companyId}/taxcodesRetrieve tax codes for this company
TaxCodesAPIApiV2CompaniesByCompanyIdTaxcodesPostPost /api/v2/companies/{companyId}/taxcodesCreate a new tax code
TaxCodesAPIApiV2TaxcodesGetGet /api/v2/taxcodesRetrieve all tax codes
TaxRatesAPIApiV2TaxratesByaddressGetGet /api/v2/taxrates/byaddressRetrieve tax rates for a specified address
TaxRatesAPIApiV2TaxratesBypostalcodeGetGet /api/v2/taxrates/bypostalcodeRetrieve tax rates for a specified country and postal code
TaxRulesAPIApiV2CompaniesByCompanyIdTaxrulesByIdDeleteDelete /api/v2/companies/{companyId}/taxrules/{id}Delete a single tax rule
TaxRulesAPIApiV2CompaniesByCompanyIdTaxrulesByIdGetGet /api/v2/companies/{companyId}/taxrules/{id}Retrieve a single tax rule
TaxRulesAPIApiV2CompaniesByCompanyIdTaxrulesByIdPutPut /api/v2/companies/{companyId}/taxrules/{id}Update a single tax rule
TaxRulesAPIApiV2CompaniesByCompanyIdTaxrulesGetGet /api/v2/companies/{companyId}/taxrulesRetrieve tax rules for this company
TaxRulesAPIApiV2CompaniesByCompanyIdTaxrulesPostPost /api/v2/companies/{companyId}/taxrulesCreate a new tax rule
TaxRulesAPIApiV2TaxrulesGetGet /api/v2/taxrulesRetrieve all tax rules
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodeAdjustPostPost /api/v2/companies/{companyCode}/transactions/{transactionCode}/adjustCorrect a previously created transaction
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodeCancelPostPost /api/v2/companies/{companyCode}/transactions/{transactionCode}/cancelCancel a transaction
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodeCommitPostPost /api/v2/companies/{companyCode}/transactions/{transactionCode}/commitConvert an invoice into a sale or purchase
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodeDeleteDelete /api/v2/companies/{companyCode}/transactions/{transactionCode}Delete a single transaction
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodeGetGet /api/v2/companies/{companyCode}/transactions/{transactionCode}Retrieve a single transaction
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsByTransactionCodePostPostPost /api/v2/companies/{companyCode}/transactions/{transactionCode}/postMark a transaction as posted to the ledger
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsCreatePostPost /api/v2/companies/{companyCode}/transactions/createCreate a new transaction
TransactionsAPIApiV2CompaniesByCompanyCodeTransactionsGetGet /api/v2/companies/{companyCode}/transactionsRetrieve all transactions
TransactionsAPIApiV2TransactionsByIdAdjustPostPost /api/v2/transactions/{id}/adjustCorrect a previously created transaction
TransactionsAPIApiV2TransactionsByIdCancelPostPost /api/v2/transactions/{id}/cancelCancel a transaction
TransactionsAPIApiV2TransactionsByIdCommitPostPost /api/v2/transactions/{id}/commitConvert an invoice into a sale or purchase
TransactionsAPIApiV2TransactionsByIdDeleteDelete /api/v2/transactions/{id}Delete a single transaction
TransactionsAPIApiV2TransactionsByIdGetGet /api/v2/transactions/{id}Retrieve a single transaction
TransactionsAPIApiV2TransactionsByIdPostPostPost /api/v2/transactions/{id}/postMark a transaction as posted to the ledger
TransactionsAPIApiV2TransactionsCreatePostPost /api/v2/transactions/createCreate a new transaction
UpcsAPIApiV2CompaniesByCompanyIdUpcsByIdDeleteDelete /api/v2/companies/{companyId}/upcs/{id}Delete a single UPC
UpcsAPIApiV2CompaniesByCompanyIdUpcsByIdGetGet /api/v2/companies/{companyId}/upcs/{id}Retrieve a single UPC
UpcsAPIApiV2CompaniesByCompanyIdUpcsByIdPutPut /api/v2/companies/{companyId}/upcs/{id}Update a single UPC
UpcsAPIApiV2CompaniesByCompanyIdUpcsGetGet /api/v2/companies/{companyId}/upcsRetrieve UPCs for this company
UpcsAPIApiV2CompaniesByCompanyIdUpcsPostPost /api/v2/companies/{companyId}/upcsCreate a new UPC
UpcsAPIApiV2UpcsGetGet /api/v2/upcsRetrieve all UPCs
UsersAPIApiV2AccountsByAccountIdUsersByIdDeleteDelete /api/v2/accounts/{accountId}/users/{id}Delete a single user
UsersAPIApiV2AccountsByAccountIdUsersByIdEntitlementsGetGet /api/v2/accounts/{accountId}/users/{id}/entitlementsRetrieve all entitlements for a single user
UsersAPIApiV2AccountsByAccountIdUsersByIdGetGet /api/v2/accounts/{accountId}/users/{id}Retrieve a single user
UsersAPIApiV2AccountsByAccountIdUsersByIdPutPut /api/v2/accounts/{accountId}/users/{id}Update a single user
UsersAPIApiV2AccountsByAccountIdUsersGetGet /api/v2/accounts/{accountId}/usersRetrieve users for this account
UsersAPIApiV2AccountsByAccountIdUsersPostPost /api/v2/accounts/{accountId}/usersCreate a new user
UsersAPIApiV2UsersGetGet /api/v2/usersRetrieve all users
UtilitiesAPIUtilitiesIsauthorizedPostPost /utilities/isauthorizedChecks authentication and authorization to one or more operations on the service.
UtilitiesAPIUtilitiesIsserviceauthorizedPostPost /utilities/isserviceauthorizedChecks if service is authorized for given service type
UtilitiesAPIUtilitiesPingGetGet /utilities/pingTests connectivity and version of the service

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

UserSecurity

  • Type: HTTP basic authentication

Example

auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
    UserName: "username",
    Password: "password",
})
r, err := client.Service.Operation(auth, args)

ApiKeySecurity

  • Type: API key
  • API key parameter name: Authorization
  • Location: HTTP header

Note, each API key must be added to a map of map[string]APIKey where the key is: Authorization and passed in as the auth context for each request.

Example

auth := context.WithValue(
		context.Background(),
		sw.ContextAPIKeys,
		map[string]sw.APIKey{
			"Authorization": {Key: "API_KEY_STRING"},
		},
	)
r, err := client.Service.Operation(auth, args)

OauthSecurity

Example

auth := context.WithValue(context.Background(), sw.ContextAccessToken, "ACCESSTOKENSTRING")
r, err := client.Service.Operation(auth, args)

Or via OAuth2 module to automatically refresh tokens and perform user authentication.

import "golang.org/x/oauth2"

/* Perform OAuth2 round trip request and obtain a token */

tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token)
auth := context.WithValue(oauth2.NoContext, sw.ContextOAuth2, tokenSource)
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author