From 33385cd27766520392433c0f7c0b941c21b2d01f Mon Sep 17 00:00:00 2001 From: steve-sweitzer Date: Mon, 14 Oct 2024 12:12:13 -0400 Subject: [PATCH] Added TimeOutInSeconds property and GetTimeOutTimeSpan method Added field, property, and method to support the timeout being specified in second instead of minutes. Minutes are not sufficiently granular. --- src/UserConfiguration.cs | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/UserConfiguration.cs b/src/UserConfiguration.cs index 22805438..c67ab24f 100644 --- a/src/UserConfiguration.cs +++ b/src/UserConfiguration.cs @@ -6,6 +6,7 @@ namespace Avalara.AvaTax.RestClient public class UserConfiguration { private int _timeOutInMinutes; + private int _timeOutInSeconds; private int _maxRetryAttempts; /// @@ -20,6 +21,26 @@ public int TimeoutInMinutes } } + /// + /// Gets or sets timeout in seconds. If set to a non-zero value, overrides TimeoutInMinutes. + /// + public int TimeoutInSeconds + { + get { return _timeOutInSeconds; } + set + { + _timeOutInSeconds = value <= 0 ? 0 : value; + } + } + + /// + /// Get for the currently set timeout period. + /// + public TimeSpan GetTimeOutTimeSpan() + { + return _timeOutInSeconds > 0 ? TimeSpan.FromSeconds(_timeOutInSeconds) : TimeSpan.FromMinutes(_timeOutInMinutes); + } + /// /// Gets or sets Maximum retry attempts /// @@ -39,6 +60,7 @@ public UserConfiguration() { this._maxRetryAttempts = 0; this._timeOutInMinutes = 20; + this._timeOutInSeconds = 0; } } -} \ No newline at end of file +}