From fb7d0cbd5d352fedd72c277de1020c254045780a Mon Sep 17 00:00:00 2001 From: "SANJUAN\\sachin.baijal" Date: Tue, 14 Dec 2021 11:39:38 -0800 Subject: [PATCH] Fixes for AVS and DEVPORT-764 --- src/AvaTaxClient.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/AvaTaxClient.cs b/src/AvaTaxClient.cs index 41b905b0..05977217 100644 --- a/src/AvaTaxClient.cs +++ b/src/AvaTaxClient.cs @@ -31,6 +31,10 @@ public partial class AvaTaxClient /// Tracks the amount of time spent on the most recent API call /// public CallDuration LastCallTime { get; set; } + /// + /// Client Id - passed in request header + /// + public readonly string ClientID; /// /// Returns the version of the SDK that was compiled @@ -62,6 +66,7 @@ public partial class AvaTaxClient /// User configuration public AvaTaxClient(string appName, string appVersion, string machineName, AvaTaxEnvironment environment, UserConfiguration userConfiguration = null) { + ClientID= String.Format("{0}; {1}; {2}; {{0}}; {3}", appName, appVersion, "CSharpRestClient", machineName); // Redo the client identifier WithClientIdentifier(appName, appVersion, machineName); if (userConfiguration != null) @@ -87,6 +92,7 @@ public AvaTaxClient(string appName, string appVersion, string machineName, AvaTa /// User configuration public AvaTaxClient(string appName, string appVersion, string machineName, Uri customEnvironment, UserConfiguration userConfiguration = null) { + ClientID = String.Format("{0}; {1}; {2}; {{0}}; {3}", appName, appVersion, "CSharpRestClient", machineName); // Redo the client identifier WithClientIdentifier(appName, appVersion, machineName); if (userConfiguration != null) @@ -176,7 +182,14 @@ public AvaTaxClient WithCustomHeader(string name, string value) /// public AvaTaxClient WithClientIdentifier(string appName, string appVersion, string machineName) { - _clientHeaders.Add(Constants.AVALARA_CLIENT_HEADER, String.Format("{0}; {1}; {2}; {3}; {4}", appName, appVersion, "CSharpRestClient", API_VERSION, machineName)); + if (!_clientHeaders.ContainsKey(Constants.AVALARA_CLIENT_HEADER)) + { + _clientHeaders.Add(Constants.AVALARA_CLIENT_HEADER, ClientID); + } + else + { + _clientHeaders[Constants.AVALARA_CLIENT_HEADER] = ClientID; + } return this; } #endregion