From d42697fc39c90febda024ba41eb44a5bc4a5571d Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 2 May 2021 20:56:32 +0200 Subject: [PATCH 1/2] Add LocationTaxContent class to hold response data from BuildTaxContentFileForLocationAsync --- src/Avalara.AvaTax.net461.csproj | 1 + src/models/LocationTaxContent.cs | 50 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/models/LocationTaxContent.cs diff --git a/src/Avalara.AvaTax.net461.csproj b/src/Avalara.AvaTax.net461.csproj index f4315210..2d3616a6 100644 --- a/src/Avalara.AvaTax.net461.csproj +++ b/src/Avalara.AvaTax.net461.csproj @@ -312,6 +312,7 @@ + diff --git a/src/models/LocationTaxContent.cs b/src/models/LocationTaxContent.cs new file mode 100644 index 00000000..b468a997 --- /dev/null +++ b/src/models/LocationTaxContent.cs @@ -0,0 +1,50 @@ +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Avalara.AvaTax.RestClient +{ + /// + /// Simple POCO + ToString() object to hold the tax information returned by the BuildTaxContentFileForLocationAsync + /// methods in AvaTaxClient + /// + /// + /// + /// Josh Waldrep - jwaldrepwork@gmail.com - 04/2021 + /// The datatypes here were derived from the response to the api route "/api/v2/companies/{companyId}/locations/{id}/pointofsaledata" + /// and need to be reviewed and commented. + /// + public class LocationTaxContent + { + public Int32? ScenarioId { get; set; } + public DateTime? EffDate { get; set; } + public DateTime? EndDate { get; set; } + public String LocationCode { get; set; } + public String TaxCode { get; set; } + public String ShipToCity { get; set; } + public String ShipToCounty { get; set; } + public String ShipToState { get; set; } + public String ShipToPostalCode { get; set; } + public String ShipToCountry { get; set; } + public String JurisType { get; set; } + public String JurisName { get; set; } + public String TaxType { get; set; } + public String Tax_Description { get; set; } + public decimal? Tax_Rate { get; set; } + public String Cap { get; set; } + public String Threshold { get; set; } + public String TaxRuleOptions { get; set; } + + /// + /// Convert this object to a JSON string of itself + /// + /// A JSON string of this object + public override string ToString() + { + return JsonConvert.SerializeObject(this, new JsonSerializerSettings() { Formatting = Formatting.Indented }); + } + } +} From 02e17b3c8a6333e0859f4cef0cd7487662acef91 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 2 May 2021 20:57:18 +0200 Subject: [PATCH 2/2] change BuildTaxContentFileForLocationAsync to load response data into new LocationTaxContent class --- src/AvaTaxApi.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/AvaTaxApi.cs b/src/AvaTaxApi.cs index d45ee862..917a7da3 100644 --- a/src/AvaTaxApi.cs +++ b/src/AvaTaxApi.cs @@ -18226,13 +18226,21 @@ public async Task BuildTaxContentFileAsync(PointOfSaleDataRequestMod /// * This API requires one of the following user roles: AccountAdmin, AccountOperator, AccountUser, CompanyAdmin, CompanyUser, Compliance Root User, ComplianceAdmin, ComplianceUser, CSPAdmin, CSPTester, FirmAdmin, FirmUser, ProStoresOperator, Registrar, SiteAdmin, SSTAdmin, SystemAdmin, TechnicalSupportAdmin, TechnicalSupportUser, TreasuryAdmin, TreasuryUser. /// * This API depends on the following active services:*Required* (all): AvaTaxPro.; /// + /// + /// + /// Josh Waldrep - jwaldrepwork@gmail.com - 04/2021 + /// This method always fails. The route specified does not return a FileResult it returns a list of tax authorities and rates + /// I was unable to find a model that matched the response so one was added. If an existing model is more appropriate it + /// probably should be used + /// + /// /// The ID number of the company that owns this location. /// The ID number of the location to retrieve point-of-sale data. /// The date for which point-of-sale data would be calculated (today by default) /// The format of the file (JSON by default) /// If specified, requests a custom partner-formatted version of the file. /// When true, the file will include jurisdiction codes in the result. - public async Task BuildTaxContentFileForLocationAsync(Int32 companyId, Int32 id, DateTime? date, PointOfSaleFileType? format, PointOfSalePartnerId? partnerId, Boolean? includeJurisCodes) + public async Task> BuildTaxContentFileForLocationAsync(Int32 companyId, Int32 id, DateTime? date, PointOfSaleFileType? format, PointOfSalePartnerId? partnerId, Boolean? includeJurisCodes) { var path = new AvaTaxPath("/api/v2/companies/{companyId}/locations/{id}/pointofsaledata"); path.ApplyField("companyId", companyId); @@ -18241,7 +18249,7 @@ public async Task BuildTaxContentFileForLocationAsync(Int32 companyI path.AddQuery("format", format); path.AddQuery("partnerId", partnerId); path.AddQuery("includeJurisCodes", includeJurisCodes); - return await RestCallAsync("GET", path, null).ConfigureAwait(false); + return await RestCallAsync>("GET", path, null).ConfigureAwait(false); }