From 3c06646ef5f0dab33f5fc18d7805bf8f79d17aaf Mon Sep 17 00:00:00 2001 From: Genevieve Conty Date: Tue, 15 Jan 2019 11:13:00 -0800 Subject: [PATCH 1/3] update to 18.12, ran update script --- src/Client.php | 4 +- src/Constants.php | 62 +++++++ src/Methods.php | 423 ++++++++++++++++++++++++++++++++++++++++++---- src/Models.php | 334 +++++++++++++++++++++++++++++++++++- 4 files changed, 783 insertions(+), 40 deletions(-) diff --git a/src/Client.php b/src/Client.php index e29283b..9d74834 100644 --- a/src/Client.php +++ b/src/Client.php @@ -168,13 +168,13 @@ protected function restCall($apiUrl, $verb, $guzzleParams) } $guzzleParams['headers'] = [ 'Accept' => 'application/json', - 'X-Avalara-Client' => "{$this->appName}; {$this->appVersion}; PhpRestClient; 18.10.5-260; {$this->machineName}" + 'X-Avalara-Client' => "{$this->appName}; {$this->appVersion}; PhpRestClient; 18.12.0; {$this->machineName}" ]; } else { $guzzleParams['headers'] = [ 'Accept' => 'application/json', 'Authorization' => 'Bearer '.$this->auth[0], - 'X-Avalara-Client' => "{$this->appName}; {$this->appVersion}; PhpRestClient; 18.10.5-260; {$this->machineName}" + 'X-Avalara-Client' => "{$this->appName}; {$this->appVersion}; PhpRestClient; 18.12.0; {$this->machineName}" ]; } diff --git a/src/Constants.php b/src/Constants.php index 84184c1..0d3aeec 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -692,6 +692,7 @@ class ErrorCodeId const C_RANGECOMPAREERROR = "RangeCompareError"; const C_RANGESETERROR = "RangeSetError"; const C_TAXPAYERNUMBERREQUIRED = "TaxpayerNumberRequired"; + const C_ENTITYLIMITEXCEEDED = "EntityLimitExceeded"; const C_COMMONPASSWORD = "CommonPassword"; const C_WEAKPASSWORD = "WeakPassword"; const C_STRINGLENGTHERROR = "StringLengthError"; @@ -726,6 +727,7 @@ class ErrorCodeId const C_NOFILTERCRITERIAEXCEPTION = "NoFilterCriteriaException"; const C_OPENCLAUSEEXCEPTION = "OpenClauseException"; const C_JSONFORMATERROR = "JsonFormatError"; + const C_INVALIDDECIMALVALUE = "InvalidDecimalValue"; const C_UNHANDLEDEXCEPTION = "UnhandledException"; const C_REPORTINGCOMPANYMUSTHAVECONTACTSERROR = "ReportingCompanyMustHaveContactsError"; const C_COMPANYPROFILENOTSET = "CompanyProfileNotSet"; @@ -1014,6 +1016,8 @@ class ErrorCodeId const C_TAXRULEREQUIRESNEXUS = "TaxRuleRequiresNexus"; const C_UPCCODENOTUNIQUE = "UPCCodeNotUnique"; const C_CANNOTUPDATESOURCEORINSTANCE = "CannotUpdateSourceOrInstance"; + const C_TAXCODEASSOCIATEDWITHITEMCODENOTFOUND = "TaxCodeAssociatedWithItemCodeNotFound"; + const C_DUPLICATESYSTEMFORITEM = "DuplicateSystemForItem"; /** * SendSales API errors @@ -1034,6 +1038,15 @@ class ErrorCodeId */ const C_TRACEDATANOTAVAILABLE = "TraceDataNotAvailable"; + /** + * Item parameter errors + */ + const C_INVALIDPARAMETERUNITMEASUREMENTTYPE = "InvalidParameterUnitMeasurementType"; + const C_PARAMETERUNITREQUIRED = "ParameterUnitRequired"; + const C_INVALIDPARAMETERVALUEDATATYPE = "InvalidParameterValueDataType"; + const C_INVALIDPARAMETERATTRIBUTETYPE = "InvalidParameterAttributeType"; + const C_SUBSCRIPTIONREQUIREDFORPARAMETER = "SubscriptionRequiredForParameter"; + } @@ -1633,6 +1646,11 @@ class AddressCategoryId */ const C_MARKETPLACEREMITSTAX = "MarketplaceRemitsTax"; + /** + * Address refers to the mailing address of your company which is not a physical location. + */ + const C_NONPHYSICAL = "NonPhysical"; + } @@ -2570,6 +2588,50 @@ class PaymentType } +/** + * What object experienced the error? + */ +class ErrorTargetCode +{ + + /** + * Error target is unknown + */ + const C_UNKNOWN = "Unknown"; + + /** + * There was an error in the request URL, querystring, or body + */ + const C_HTTPREQUEST = "HttpRequest"; + + /** + * There was an error in the HTTP Request headers + */ + const C_HTTPREQUESTHEADERS = "HttpRequestHeaders"; + + /** + * Some data provided by the user was incorrect + */ + const C_INCORRECTDATA = "IncorrectData"; + + /** + * There was an error in the AvaTax API Server + */ + const C_AVATAXAPISERVER = "AvaTaxApiServer"; + + /** + * There was an error in the Avalara Identity Server + */ + const C_AVALARAIDENTITYSERVER = "AvalaraIdentityServer"; + + /** + * The customer's account setup does not permit certain actions + */ + const C_CUSTOMERACCOUNTSETUP = "CustomerAccountSetup"; + +} + + /** * Refund types */ diff --git a/src/Methods.php b/src/Methods.php index 1458e7a..02e70bd 100644 --- a/src/Methods.php +++ b/src/Methods.php @@ -67,15 +67,14 @@ public function accountResetLicenseKey($id, $model) * * * @param int $id The ID of the account to activate - * @param string $include Elements to include when fetching the account * @param ActivateAccountModel $model The activation request * @return AccountModel */ - public function activateAccount($id, $include=null, $model) + public function activateAccount($id, $model) { $path = "/api/v2/accounts/{$id}/activate"; $guzzleParams = [ - 'query' => ['$include' => $include], + 'query' => [], 'body' => json_encode($model) ]; return $this->restCall($path, 'POST', $guzzleParams); @@ -580,7 +579,7 @@ public function deleteAvaFileForm($id) * Get the AvaFileForm object identified by this URL. * * - * @param string $id The primary key of this AvaFileForm + * @param int $id The primary key of this AvaFileForm * @return AvaFileFormModel */ public function getAvaFileForm($id) @@ -973,14 +972,15 @@ public function listCertExpressInvitations($companyId, $include=null, $filter=nu * * * @param int $companyId The ID number of the company recording this certificate + * @param boolean $preValidatedExemptionReason If set to true, the certificate will bypass the human verification process. * @param CertificateModel[] $model Certificates to be created * @return CertificateModel[] */ - public function createCertificates($companyId, $model) + public function createCertificates($companyId, $preValidatedExemptionReason, $model) { $path = "/api/v2/companies/{$companyId}/certificates"; $guzzleParams = [ - 'query' => [], + 'query' => ['$preValidatedExemptionReason' => $preValidatedExemptionReason], 'body' => json_encode($model) ]; return $this->restCall($path, 'POST', $guzzleParams); @@ -1666,15 +1666,15 @@ public function getCompany($id, $include=null) * Retrieve a list of all configuration settings tied to this company. * * Configuration settings provide you with the ability to control features of your account and of your - * tax software. The category names `AvaCertServiceConfig` is reserved for - * Avalara internal software configuration values; to store your own account-level settings, please + * tax software. The category name `AvaCertServiceConfig` is reserved for + * Avalara internal software configuration values; to store your own company-level settings, please * create a new category name that begins with `X-`, for example, `X-MyCustomCategory`. * * Company settings are permanent settings that cannot be deleted. You can set the value of a - * company setting to null if desired. + * company setting to null if desired and if the particular setting supports it. * - * Avalara-based account settings for `AvaCertServiceConfig` affect your account's exemption certificate - * processing, and should only be changed with care. + * Avalara-based company settings for `AvaCertServiceConfig` affect your company's exemption certificate + * processing, and should be changed with care. * * * @param int $id @@ -1802,20 +1802,20 @@ public function queryCompanies($include=null, $filter=null, $top=null, $skip=nul } /** - * Change configuration settings for this account + * Change configuration settings for this company * - * Update configuration settings tied to this account. + * Update configuration settings tied to this company. * * Configuration settings provide you with the ability to control features of your account and of your * tax software. The category names `AvaCertServiceConfig` is reserved for - * Avalara internal software configuration values; to store your own account-level settings, please + * Avalara internal software configuration values; to store your own company-level settings, please * create a new category name that begins with `X-`, for example, `X-MyCustomCategory`. * * Company settings are permanent settings that cannot be deleted. You can set the value of a - * company setting to null if desired. + * company setting to null if desired and if the particular setting supports it. * - * Avalara-based account settings for `AvaCertServiceConfig` affect your account's exemption certificate - * processing, and should only be changed with care. + * Avalara-based company settings for `AvaCertServiceConfig` affect your company's exemption certificate + * processing, and should be changed with care. * * * @param int $id @@ -2508,10 +2508,10 @@ public function getCrossBorderCode($country, $hsCode) * Test whether a form supports online login verification * * This API is intended to be useful to identify whether the user should be allowed - * to automatically verify their login and password. + * to automatically verify their login and password. This API will provide a result only if the form supports automatic online login verification. * * - * @param string $form The name of the form you would like to verify. This can be the tax form code or the legacy return name + * @param string $form The name of the form you would like to verify. This is the tax form code * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. @@ -3400,6 +3400,30 @@ public function listParameters($filter=null, $top=null, $skip=null, $orderBy=nul return $this->restCall($path, 'GET', $guzzleParams); } + /** + * Retrieve the parameters by companyCode and itemCode. + * + * Returns the list of parameters based on the company country and state jurisdiction and the item code. + * + * + * @param string $companyCode Company code. + * @param string $itemCode Item code. + * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. + * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. + * @param string $orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`. + * @return FetchResult + */ + public function listParametersByItem($companyCode, $itemCode, $filter=null, $top=null, $skip=null, $orderBy=null) + { + $path = "/api/v2/definitions/parameters/byitem/{$companyCode}/{$itemCode}"; + $guzzleParams = [ + 'query' => ['$filter' => $filter, '$top' => $top, '$skip' => $skip, '$orderBy' => $orderBy], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + /** * Retrieve the full list of Avalara-supported permissions * @@ -3473,6 +3497,57 @@ public function listPreferredPrograms($filter=null, $top=null, $skip=null, $orde return $this->restCall($path, 'GET', $guzzleParams); } + /** + * List all available product classification systems. + * + * List all available product classification systems. + * + * Tax authorities use product classification systems as a way to identify products and associate them with a tax rate. + * More than one tax authority might use the same product classification system, but they might charge different tax rates for products. + * + * + * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. + * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. + * @param string $orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`. + * @return FetchResult + */ + public function listProductClassificationSystems($filter=null, $top=null, $skip=null, $orderBy=null) + { + $path = "/api/v2/definitions/productclassificationsystems"; + $guzzleParams = [ + 'query' => ['$filter' => $filter, '$top' => $top, '$skip' => $skip, '$orderBy' => $orderBy], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + + /** + * List all product classification systems available to a company based on its nexus. + * + * Lists all product classification systems available to a company based on its nexus. + * + * Tax authorities use product classification systems as a way to identify products and associate them with a tax rate. + * More than one tax authority might use the same product classification system, but they might charge different tax rates for products. + * + * + * @param string $companyCode The company code. + * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. + * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. + * @param string $orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`. + * @return FetchResult + */ + public function listProductClassificationSystemsByCompany($companyCode, $filter=null, $top=null, $skip=null, $orderBy=null) + { + $path = "/api/v2/definitions/productclassificationsystems/bycompany/{$companyCode}"; + $guzzleParams = [ + 'query' => ['$filter' => $filter, '$top' => $top, '$skip' => $skip, '$orderBy' => $orderBy], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + /** * Retrieve the full list of rate types for each country * @@ -4812,7 +4887,7 @@ public function getFilingAttachmentsTraceFile($companyId, $year, $month) * @param int $companyId The ID of the company that owns the filings. * @param int $id The id of the filing return your retrieving * @param boolean $details Indicates if you would like the credit details returned - * @return FetchResult + * @return FilingReturnModel */ public function getFilingReturn($companyId, $id, $details) { @@ -5291,6 +5366,64 @@ public function fundingRequestStatus($id) return $this->restCall($path, 'GET', $guzzleParams); } + /** + * Add classifications to an item. + * + * Add classifications to an item. + * + * A classification is the code for a product in a particular tax system. Classifications enable an item to be used in multiple tax systems which may have different tax rates for a product. + * + * When an item is used in a transaction, the applicable classification will be used to determine the appropriate tax rate. + * + * An item may only have one classification per tax system. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id. + * @param ItemClassificationInputModel[] $model The item classifications you wish to create. + * @return ItemClassificationOutputModel[] + */ + public function createItemClassifications($companyId, $itemId, $model) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/classifications"; + $guzzleParams = [ + 'query' => [], + 'body' => json_encode($model) + ]; + return $this->restCall($path, 'POST', $guzzleParams); + } + + /** + * Add parameters to an item. + * + * Add parameters to an item. + * + * Some items can be taxed differently depending on the properties of that item, such as the item grade or by a particular measurement of that item. In AvaTax, these tax-affecting properties are called "parameters". + * + * A parameter added to an item will be used by default in tax calculation but will not show on the transaction line referencing the item . + * + * A parameter specified on a transaction line will override an item parameter if they share the same parameter name. + * + * To see available parameters for this item, call `/api/v2/definitions/parameters?$filter=attributeType eq Product` + * + * Some parameters are only available for use if you have subscribed to specific AvaTax services. To see which parameters you are able to use, add the query parameter "$showSubscribed=true" to the parameter definition call above. + * + * + * @param int $companyId The ID of the company that owns this item parameter. + * @param int $itemId The item id. + * @param ItemParameterModel[] $model The item parameters you wish to create. + * @return ItemParameterModel[] + */ + public function createItemParameters($companyId, $itemId, $model) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/parameters"; + $guzzleParams = [ + 'query' => [], + 'body' => json_encode($model) + ]; + return $this->restCall($path, 'POST', $guzzleParams); + } + /** * Create a new item * @@ -5301,6 +5434,8 @@ public function fundingRequestStatus($id) * and other data fields. AvaTax will automatically look up each `itemCode` and apply the correct tax codes and parameters * from the item table instead. This allows your CreateTransaction call to be as simple as possible, and your tax compliance * team can manage your item catalog and adjust the tax behavior of items without having to modify your software. + * + * The tax code takes precedence over the tax code id if both are provided. * * * @param int $companyId The ID of the company that owns this item. @@ -5320,13 +5455,15 @@ public function createItems($companyId, $model) /** * Delete a single item * - * Marks the item object at this URL as deleted. + * Deletes the item object at this URL. * * Items are a way of separating your tax calculation process from your tax configuration details. If you choose, you * can provide `itemCode` values for each `CreateTransaction()` API call rather than specifying tax codes, parameters, descriptions, * and other data fields. AvaTax will automatically look up each `itemCode` and apply the correct tax codes and parameters * from the item table instead. This allows your CreateTransaction call to be as simple as possible, and your tax compliance * team can manage your item catalog and adjust the tax behavior of items without having to modify your software. + * + * Deleting an item will also delete the parameters and classifications associated with that item. * * * @param int $companyId The ID of the company that owns this item. @@ -5343,6 +5480,58 @@ public function deleteItem($companyId, $id) return $this->restCall($path, 'DELETE', $guzzleParams); } + /** + * Delete a single item classification. + * + * Delete a single item classification. + * + * A classification is the code for a product in a particular tax system. Classifications enable an item to be used in multiple tax systems which may have different tax rates for a product. + * + * When an item is used in a transaction, the applicable classification will be used to determine the appropriate tax rate. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id. + * @param int $id The item classification id. + * @return ErrorDetail[] + */ + public function deleteItemClassification($companyId, $itemId, $id) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/classifications/{$id}"; + $guzzleParams = [ + 'query' => [], + 'body' => null + ]; + return $this->restCall($path, 'DELETE', $guzzleParams); + } + + /** + * Delete a single item parameter + * + * Delete a single item parameter. + * + * Some items can be taxed differently depending on the properties of that item, such as the item grade or by a particular measurement of that item. In AvaTax, these tax-affecting properties are called "parameters". + * + * A parameter added to an item will be used by default in tax calculation but will not show on the transaction line referencing the item . + * + * A parameter specified on a transaction line will override an item parameter if they share the same parameter name. + * + * + * @param int $companyId The company id + * @param int $itemId The item id + * @param int $id The parameter id + * @return ErrorDetail[] + */ + public function deleteItemParameter($companyId, $itemId, $id) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/parameters/{$id}"; + $guzzleParams = [ + 'query' => [], + 'body' => null + ]; + return $this->restCall($path, 'DELETE', $guzzleParams); + } + /** * Retrieve a single item * @@ -5357,11 +5546,37 @@ public function deleteItem($companyId, $id) * * @param int $companyId The ID of the company that owns this item object * @param int $id The primary key of this item + * @param string $include A comma separated list of additional data to retrieve. * @return ItemModel */ - public function getItem($companyId, $id) + public function getItem($companyId, $id, $include=null) { $path = "/api/v2/companies/{$companyId}/items/{$id}"; + $guzzleParams = [ + 'query' => ['$include' => $include], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + + /** + * Retrieve a single item classification. + * + * Retrieve a single item classification. + * + * A classification is the code for a product in a particular tax system. Classifications enable an item to be used in multiple tax systems which may have different tax rates for a product. + * + * When an item is used in a transaction, the applicable classification will be used to determine the appropriate tax rate. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id. + * @param int $id The item classification id. + * @return ItemClassificationOutputModel + */ + public function getItemClassification($companyId, $itemId, $id) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/classifications/{$id}"; $guzzleParams = [ 'query' => [], 'body' => null @@ -5369,6 +5584,97 @@ public function getItem($companyId, $id) return $this->restCall($path, 'GET', $guzzleParams); } + /** + * Retrieve a single item parameter + * + * Retrieve a single item parameter. + * + * Some items can be taxed differently depending on the properties of that item, such as the item grade or by a particular measurement of that item. In AvaTax, these tax-affecting properties are called "parameters". + * + * A parameter added to an item will be used by default in tax calculation but will not show on the transaction line referencing the item . + * + * A parameter specified on a transaction line will override an item parameter if they share the same parameter name. + * + * + * @param int $companyId The company id + * @param int $itemId The item id + * @param int $id The parameter id + * @return ItemParameterModel + */ + public function getItemParameter($companyId, $itemId, $id) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/parameters/{$id}"; + $guzzleParams = [ + 'query' => [], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + + /** + * Retrieve classifications for an item. + * + * List classifications for an item. + * + * A classification is the code for a product in a particular tax system. Classifications enable an item to be used in multiple tax systems which may have different tax rates for a product. + * + * When an item is used in a transaction, the applicable classification will be used to determine the appropriate tax rate. + * + * Search for specific objects using the criteria in the `$filter` classification; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * Paginate your results using the `$top`, `$skip`, and `$orderby` classifications. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id. + * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. + * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. + * @param string $orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`. + * @return FetchResult + */ + public function listItemClassifications($companyId, $itemId, $filter=null, $top=null, $skip=null, $orderBy=null) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/classifications"; + $guzzleParams = [ + 'query' => ['$filter' => $filter, '$top' => $top, '$skip' => $skip, '$orderBy' => $orderBy], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + + /** + * Retrieve parameters for an item + * + * List parameters for an item. + * + * Some items can be taxed differently depending on the properties of that item, such as the item grade or by a particular measurement of that item. In AvaTax, these tax-affecting properties are called "parameters". + * + * A parameter added to an item will be used by default in tax calculation but will not show on the transaction line referencing the item . + * + * A parameter specified on a transaction line will override an item parameter if they share the same parameter name. + * + * Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * Paginate your results using the `$top`, `$skip`, and `$orderby` parameters. + * + * + * @param int $companyId The company id + * @param int $itemId The item id + * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . + * @param int $top If nonzero, return no more than this number of results. Used with `$skip` to provide pagination for large datasets. Unless otherwise specified, the maximum number of records that can be returned from an API call is 1,000 records. + * @param int $skip If nonzero, skip this number of results before returning data. Used with `$top` to provide pagination for large datasets. + * @param string $orderBy A comma separated list of sort statements in the format `(fieldname) [ASC|DESC]`, for example `id ASC`. + * @return FetchResult + */ + public function listItemParameters($companyId, $itemId, $filter=null, $top=null, $skip=null, $orderBy=null) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/parameters"; + $guzzleParams = [ + 'query' => ['$filter' => $filter, '$top' => $top, '$skip' => $skip, '$orderBy' => $orderBy], + 'body' => null + ]; + return $this->restCall($path, 'GET', $guzzleParams); + } + /** * Retrieve items for this company * @@ -5386,7 +5692,8 @@ public function getItem($companyId, $id) * * You may specify one or more of the following values in the `$include` parameter to fetch additional nested data, using commas to separate multiple values: * - * * Attributes + * * Parameters + * * Classifications * * * @param int $companyId The ID of the company that defined these items @@ -5421,10 +5728,6 @@ public function listItemsByCompany($companyId, $filter=null, $include=null, $top * Search for specific objects using the criteria in the `$filter` parameter; full documentation is available on [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . * * Paginate your results using the `$top`, `$skip`, and `$orderby` parameters. - * - * You may specify one or more of the following values in the `$include` parameter to fetch additional nested data, using commas to separate multiple values: - * - * * Attributes * * * @param string $filter A filter statement to identify specific records to retrieve. For more information on filtering, see [Filtering in REST](http://developer.avalara.com/avatax/filtering-in-rest/) . @@ -5457,6 +5760,8 @@ public function queryItems($filter=null, $include=null, $top=null, $skip=null, $ * * All data from the existing object will be replaced with data in the object you PUT. To set a field's value to null, * you may either set its value to null or omit that field from the object you post. + * + * The tax code takes precedence over the tax code id if both are provided. * * * @param int $companyId The ID of the company that this item belongs to. @@ -5474,6 +5779,62 @@ public function updateItem($companyId, $id, $model) return $this->restCall($path, 'PUT', $guzzleParams); } + /** + * Update an item classification. + * + * Update an item classification. + * + * A classification is the code for a product in a particular tax system. Classifications enable an item to be used in multiple tax systems which may have different tax rates for a product. + * + * When an item is used in a transaction, the applicable classification will be used to determine the appropriate tax rate. + * + * An item may only have one classification per tax system. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id. + * @param int $id The item classification id. + * @param ItemClassificationInputModel $model The item object you wish to update. + * @return ItemClassificationOutputModel + */ + public function updateItemClassification($companyId, $itemId, $id, $model) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/classifications/{$id}"; + $guzzleParams = [ + 'query' => [], + 'body' => json_encode($model) + ]; + return $this->restCall($path, 'PUT', $guzzleParams); + } + + /** + * Update an item parameter + * + * Update an item parameter. + * + * Some items can be taxed differently depending on the properties of that item, such as the item grade or by a particular measurement of that item. In AvaTax, these tax-affecting properties are called "parameters". + * + * A parameter added to an item will be used by default in tax calculation but will not show on the transaction line referencing the item . + * + * A parameter specified on a transaction line will override an item parameter if they share the same parameter name. + * + * + * @param int $companyId The company id. + * @param int $itemId The item id + * @param int $id The item parameter id + * @param ItemParameterModel $model The item object you wish to update. + * @return ItemParameterModel + */ + public function updateItemParameter($companyId, $itemId, $id, $model) + { + $path = "/api/v2/companies/{$companyId}/items/{$itemId}/parameters/{$id}"; + $guzzleParams = [ + 'query' => [], + 'body' => json_encode($model) + ]; + return $this->restCall($path, 'PUT', $guzzleParams); + } + /** * Create one or more overrides * @@ -7259,14 +7620,15 @@ public function deleteSubscription($accountId, $id) * * * @param int $userId The unique ID of the user whose password will be changed + * @param boolean $unmigrateFromAi If user's password was migrated to AI, undo this. * @param SetPasswordModel $model The new password for this user * @return string */ - public function resetPassword($userId, $model) + public function resetPassword($userId, $unmigrateFromAi, $model) { $path = "/api/v2/passwords/{$userId}/reset"; $guzzleParams = [ - 'query' => [], + 'query' => ['unmigrateFromAi' => $unmigrateFromAi], 'body' => json_encode($model) ]; return $this->restCall($path, 'POST', $guzzleParams); @@ -8720,6 +9082,7 @@ public function getTransactionByCodeAndType($companyCode, $transactionCode, $doc * * Addresses * * SummaryOnly (omit lines and details - reduces API response size) * * LinesOnly (omit details - reduces API response size) + * * TaxDetailsByTaxType - Includes the aggregated tax, exempt tax, taxable and non-taxable for each tax type returned in the transaction summary. * * * @param int $id The unique ID number of the transaction to retrieve @@ -8968,7 +9331,7 @@ public function verifyTransaction($companyCode, $transactionCode, $documentType, * @param string $companyCode The company code of the company that recorded this transaction * @param string $transactionCode The transaction code to void * @param string $documentType (Optional): The document type of the transaction to void. If not provided, the default is SalesInvoice. (See DocumentType::* for a list of allowable values) - * @param VoidTransactionModel $model The void request you wish to execute + * @param VoidTransactionModel $model The void request you wish to execute. To void a transaction the code must be set to 'DocVoided' * @return TransactionModel */ public function voidTransaction($companyCode, $transactionCode, $documentType, $model) diff --git a/src/Models.php b/src/Models.php index 319e160..ae7b64a 100644 --- a/src/Models.php +++ b/src/Models.php @@ -192,7 +192,7 @@ class UserModel public $securityRoleId; /** - * @var string The status of the user's password. (See PasswordStatusId::* for a list of allowable values) + * @var string The status of the user's password. For a new user created, this is always going to be `UserMustChange` (See PasswordStatusId::* for a list of allowable values) */ public $passwordStatus; @@ -1875,6 +1875,11 @@ class CertificateModel */ public $exemptionReason; + /** + * @var string The status of the certificate + */ + public $status; + /** * @var string The date/time when this record was created. */ @@ -2435,12 +2440,12 @@ class ItemModel public $itemCode; /** - * @var int The unique ID number of the tax code that is applied when selling this item. When creating or updating an item, you can either specify the Tax Code ID number or the Tax Code string; you do not need to specify both values. + * @var int DEPRECATED - For identifying an `Item` with `Avalara TaxCode`, please call the [CreateItemClassification API] with your ItemCode and the Avalara TaxCode. The unique ID number of the tax code that is applied when selling this item. When creating or updating an item, you can either specify the Tax Code ID number or the Tax Code string; you do not need to specify both values. */ public $taxCodeId; /** - * @var string The unique code string of the Tax Code that is applied when selling this item. When creating or updating an item, you can either specify the Tax Code ID number or the Tax Code string; you do not need to specify both values. + * @var string DEPRECATED - For identifying an `Item` with `Avalara TaxCode`, please call the [CreateItemClassification API] with your ItemCode and the Avalara TaxCode. The unique code string of the Tax Code that is applied when selling this item. When creating or updating an item, you can either specify the Tax Code ID number or the Tax Code string; you do not need to specify both values. */ public $taxCode; @@ -2449,6 +2454,11 @@ class ItemModel */ public $description; + /** + * @var string A way to group similar items. + */ + public $itemGroup; + /** * @var string The date when this record was created. */ @@ -2469,6 +2479,16 @@ class ItemModel */ public $modifiedUserId; + /** + * @var ClassificationModel[] List of classifications that belong to this item. A single classification consits of a productCode and a systemCode for a particular item. + */ + public $classifications; + + /** + * @var ItemParameterModel[] List of item parameters. + */ + public $parameters; + } /** @@ -3332,6 +3352,57 @@ class EcmsModel } +/** + * Represents a classification for a given item. + */ +class ClassificationModel +{ + + /** + * @var string The product code of an item in a given system. + */ + public $productCode; + + /** + * @var string The system code in which the product belongs. + */ + public $systemCode; + +} + +/** + * Represents a parameter associated with an item. + */ +class ItemParameterModel +{ + + /** + * @var int The id of the parameter. + */ + public $id; + + /** + * @var string The parameter's name. + */ + public $name; + + /** + * @var string The value for the parameter. + */ + public $value; + + /** + * @var string The unit of measurement code for the parameter. + */ + public $unit; + + /** + * @var int The item id + */ + public $itemId; + +} + /** * Represents the answer to one local jurisdiction question for a location. */ @@ -4381,7 +4452,7 @@ class TransactionModel public $totalTaxable; /** - * @var float The amount of tax that AvaTax calculated for the transaction. If you used a `taxOverride` of type `taxAmount` for any lines in this transaction, this value will still represent the amount that AvaTax calculated for this transaction, although the field `totalTax` will be the total amount of tax after all overrides are applied. You can compare the `totalTax` and `totalTaxCalculated` fields to check for any discrepancies between an external tax calculation provider and the calculation performed by AvaTax. + * @var float The amount of tax that AvaTax calculated for the transaction. If you used a `taxOverride` of type `taxAmount` for any lines in this transaction, this value will represent the amount that AvaTax calculated for this transaction without applying the override. The field `totalTax` will be the total amount of tax after all overrides are applied. You can compare the `totalTax` and `totalTaxCalculated` fields to check for any discrepancies between an external tax calculation provider and the calculation performed by AvaTax. */ public $totalTaxCalculated; @@ -4659,7 +4730,7 @@ class TransactionLineModel public $taxableAmount; /** - * @var float The amount of tax that AvaTax calculated for the transaction. If you used a `taxOverride` of type `taxAmount` for this line, there will be a difference between the `tax` field which represents your override, and the `taxCalculated` field which represents the amount of tax that AvaTax calculated for this line. You can compare the `tax` and `taxCalculated` fields to check for any discrepancies between an external tax calculation provider and the calculation performed by AvaTax. + * @var float The amount of tax that AvaTax calculated for the transaction. If you used a `taxOverride` of type `taxAmount`, there may be a difference between the `tax` field which applies your override, and the `taxCalculated` field which represents the amount of tax that AvaTax calculated without the override. You can compare the `tax` and `taxCalculated` fields to check for any discrepancies between an external tax calculation provider and the calculation performed by AvaTax. */ public $taxCalculated; @@ -4933,7 +5004,7 @@ class TransactionSummary public $tax; /** - * @var float Tax Calculated by Avalara AvaTax. This may be overriden by a TaxOverride.TaxAmount. + * @var float The amount of tax that AvaTax calculated for the transaction. If you used a `taxOverride` of type `taxAmount`, there may be a difference between the `tax` field which applies your override, and the `TaxCalculated` field which represents the amount of tax that AvaTax calculated for this transaction without override. You can use this for comparison. */ public $taxCalculated; @@ -5177,7 +5248,7 @@ class TransactionLineDetailModel public $taxRegionId; /** - * @var float The amount of tax that was calculated. This amount may be different if a tax override was used. If the customer specified a tax override, this calculated tax value represents the amount of tax that would have been charged if Avalara had calculated the tax for the rule. + * @var float The amount of tax that AvaTax calculated. If an override for tax amount is used, there may be a difference between the tax field which applies your override, and the this amount that is calculated without override. */ public $taxCalculated; @@ -5530,6 +5601,31 @@ class ParameterModel */ public $regularExpression; + /** + * @var string Label that helps the user to identify a parameter + */ + public $label; + + /** + * @var string A help url that provides more information about the parameter + */ + public $helpUrl; + + /** + * @var string The type of parameter as determined by its application, e.g. Product, Transaction, Calculated + */ + public $attributeType; + + /** + * @var string[] If the parameter is of enumeration data type, then this list will be populated with all of the possible enumeration values. + */ + public $values; + + /** + * @var string The unit of measurement type of the parameter + */ + public $measurementType; + } /** @@ -5778,6 +5874,72 @@ class CurrencyModel } +/** + * Represents a product classification system. + */ +class ProductClassificationSystemModel +{ + + /** + * @var int Its Integer SystemId value for System + */ + public $systemId; + + /** + * @var string The System code for this System. + */ + public $systemCode; + + /** + * @var string A friendly human-readable name representing this System. + */ + public $description; + + /** + * @var string custom value set for the system + */ + public $customsValue; + + /** + * @var ProductSystemCountryModel[] List of all countries that belong to the system including + */ + public $countries; + +} + +/** + * Represents a System Country. + */ +class ProductSystemCountryModel +{ + + /** + * @var int Its Integer SystemCountryId value for SystemCountry + */ + public $systemCountryId; + + /** + * @var int Its Integer SystemId value for SystemCountry + */ + public $systemId; + + /** + * @var string string value of country code for SystemCountry + */ + public $country; + + /** + * @var string DateTime as EffDate for SystemCountry + */ + public $effDate; + + /** + * @var string DateTime as EffDate for SystemCountry + */ + public $endDate; + +} + /** * Tax Authority Type Model */ @@ -9205,6 +9367,152 @@ class FilingsCheckupAuthorityModel } +/** + * Product classification input model. + */ +class ItemClassificationInputModel +{ + + /** + * @var string The product code of an item in a given system. + */ + public $productCode; + + /** + * @var string The system code in which the product belongs. + */ + public $systemCode; + +} + +/** + * Product classification output model. + */ +class ItemClassificationOutputModel +{ + + /** + * @var int The unique ID number of this product. + */ + public $id; + + /** + * @var int The unique ID number of the item this product belongs to. + */ + public $itemId; + + /** + * @var int The system id which the product belongs. + */ + public $systemId; + + /** + * @var string A unique code representing this item. + */ + public $productCode; + + /** + * @var string A unique code representing this item. + */ + public $systemCode; + +} + +/** + * Represents a request to sync items. + */ +class SyncItemsRequestModel +{ + + /** + * @var ItemSyncModel[] A list of items to sync with AvaTax. + */ + public $items; + +} + +/** + * An abridged item model used for syncing product catalogs with AvaTax. + */ +class ItemSyncModel +{ + + /** + * @var string A unique code representing this item. + */ + public $itemCode; + + /** + * @var string A friendly description of the item. If your company has enrolled in Streamlined Sales Tax, this description must be auditable. + */ + public $description; + + /** + * @var string A group to which the item belongs. + */ + public $itemGroup; + + /** + * @var string The tax code of the item (optional) + */ + public $taxCode; + +} + +/** + * The response returned after an item sync was requested. + */ +class SyncItemsResponseModel +{ + + /** + * @var string The status of the request + */ + public $status; + +} + +/** + * Helper function for throwing known error response + */ +class ErrorResult +{ + + /** + * @var ErrorInfo Information about the error(s) + */ + public $error; + +} + +/** + * Information about the error that occurred + */ +class ErrorInfo +{ + + /** + * @var string Type of error that occurred (See ErrorCodeId::* for a list of allowable values) + */ + public $code; + + /** + * @var string Short one-line message to summaryize what went wrong + */ + public $message; + + /** + * @var string What object or service caused the error? (See ErrorTargetCode::* for a list of allowable values) + */ + public $target; + + /** + * @var ErrorDetail[] Array of detailed error messages + */ + public $details; + +} + /** * Tells you whether this location object has been correctly set up to the local jurisdiction's standards */ @@ -9781,7 +10089,7 @@ class VoidTransactionModel { /** - * @var string Please specify the reason for voiding or cancelling this transaction (See VoidReasonCode::* for a list of allowable values) + * @var string Please specify the reason for voiding or cancelling this transaction. To void the transaction, please specify the reason 'DocVoided'. If you do not provide a reason, the void command will fail. (See VoidReasonCode::* for a list of allowable values) */ public $code; @@ -10210,6 +10518,11 @@ class NoticeModel */ public $complianceContactId; + /** + * @var string The tax form code of the notice + */ + public $taxFormCode; + /** * @var string The document reference of the notice */ @@ -10913,6 +11226,11 @@ class PointOfSaleDataRequestModel */ public $taxCodes; + /** + * @var string[] A list of item codes to include in this point-of-sale file. If no item codes are specified, responese will include all distinct item codes associated with the Items within your company. + */ + public $itemCodes; + /** * @var string[] A list of location codes to include in this point-of-sale file. If no location codes are specified, response will include all locations within your company. */ From 9bc7b9696a55e8dd1530a179dca8c92936119761 Mon Sep 17 00:00:00 2001 From: Genevieve Conty Date: Tue, 15 Jan 2019 14:12:27 -0800 Subject: [PATCH 2/3] updated readme code example --- README.md | 4 ++-- composer.json | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3e49efe..2168fd4 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ To use the AvaTax PHP SDK from Composer: The PHP SDK uses a fluent interface to define a connection to AvaTax and to make API calls to calculate tax on transactions. Here's an example of connecting to the API. -``` +```php withAddress('ShipFrom', '123 Main Street', null, null, 'Irvine', 'CA', ->create(); echo('

Transaction #2

'); echo('
' . json_encode($t, JSON_PRETTY_PRINT) . '
'); - +?> ``` diff --git a/composer.json b/composer.json index c30ac68..2ffc646 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,10 @@ { "name": "Bob Maidens", "email": "bob.maidens@avalara.com" + }, + { + "name": "Genevieve Conty", + "email": "genevieve.conty@avalara.com" } ], "license": "Apache-2.0", From 713789bb012c80bf3be3f52daff98a28ed874e3a Mon Sep 17 00:00:00 2001 From: Genevieve Conty Date: Tue, 15 Jan 2019 14:56:22 -0800 Subject: [PATCH 3/3] added space to readme code ex --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2168fd4..931d68b 100644 --- a/README.md +++ b/README.md @@ -79,5 +79,6 @@ $t = $tb->withAddress('ShipFrom', '123 Main Street', null, null, 'Irvine', 'CA', ->create(); echo('

Transaction #2

'); echo('
' . json_encode($t, JSON_PRETTY_PRINT) . '
'); + ?> ```