From 43fe835cea69f77481b78466af6897ad8fc91649 Mon Sep 17 00:00:00 2001 From: Elye Mittelman Date: Wed, 28 Aug 2024 11:16:21 -0400 Subject: [PATCH] Adding back Constructor with HttpClient --- Xero.NetStandard.OAuth2/Client/ApiClient.cs | 37 +++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Xero.NetStandard.OAuth2/Client/ApiClient.cs b/Xero.NetStandard.OAuth2/Client/ApiClient.cs index 39de7452..8abb3409 100644 --- a/Xero.NetStandard.OAuth2/Client/ApiClient.cs +++ b/Xero.NetStandard.OAuth2/Client/ApiClient.cs @@ -265,6 +265,43 @@ public ApiClient(string basePath) _baseUrl = basePath; } + /// + /// Initializes a new instance of the , defaulting to the global configurations' base url. + /// + /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, HttpClientHandler handler = null) : + this(client, Xero.NetStandard.OAuth2.Client.GlobalConfiguration.Instance.BasePath, handler) + { + } + + /// + /// Initializes a new instance of the . + /// + /// An instance of HttpClient. + /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, string basePath, HttpClientHandler handler = null) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClientHandler = handler; + _httpClient = client; + _baseUrl = basePath; + } + /// /// Disposes resources if they were created by us ///