diff --git a/src/Postmark/PostmarkAdminClient.cs b/src/Postmark/PostmarkAdminClient.cs
index c97b95c..6ea769b 100644
--- a/src/Postmark/PostmarkAdminClient.cs
+++ b/src/Postmark/PostmarkAdminClient.cs
@@ -19,8 +19,9 @@ public class PostmarkAdminClient : PostmarkDotNet.PostmarkClientBase
///
/// The "accountToken" can be found by logging into your Postmark and navigating to https://postmarkapp.com/account/edit - Keep this token secret and safe.
/// Optionally override the base url to the API. For example, you may fallback to HTTP (non-SSL) if your app requires it, though, this is not recommended.
- public PostmarkAdminClient(string accountToken, string apiBaseUri = "https://api.postmarkapp.com")
- : base(apiBaseUri)
+ /// to processes HTTP interactions.
+ public PostmarkAdminClient(string accountToken, string apiBaseUri = "https://api.postmarkapp.com", ISimpleHttpClient client = null)
+ : base(apiBaseUri, client)
{
_authToken = accountToken;
}
@@ -112,7 +113,7 @@ public async Task CreateServerAsync(String name, string color =
public async Task EditServerAsync(int serverId, String name = null, string color = null,
bool? rawEmailEnabled = null, bool? smtpApiActivated = null, string inboundHookUrl = null,
string bounceHookUrl = null, string openHookUrl = null, bool? postFirstOpenOnly = null,
- bool? trackOpens = null, string inboundDomain = null, int? inboundSpamThreshold = null,
+ bool? trackOpens = null, string inboundDomain = null, int? inboundSpamThreshold = null,
LinkTrackingOptions? trackLinks = null, string clickHookUrl = null, string deliveryHookUrl = null, bool? enableSmtpApiErrorHooks = null)
{
diff --git a/src/Postmark/PostmarkClient.cs b/src/Postmark/PostmarkClient.cs
index 820b42d..0ce2f70 100644
--- a/src/Postmark/PostmarkClient.cs
+++ b/src/Postmark/PostmarkClient.cs
@@ -33,8 +33,9 @@ protected override string AuthHeaderName
///
/// The base uri to use when connecting to Postmark. You should rarely need to modify this, except if you want to disable TLS (not recommended), or you are using a proxy of some sort to connect to the API.
/// Used for requests that require server level privileges. This token can be found on the Credentials tab under your Postmark server.
- public PostmarkClient(string serverToken, string apiBaseUri = "https://api.postmarkapp.com")
- : base(apiBaseUri)
+ /// to processes HTTP interactions.
+ public PostmarkClient(string serverToken, string apiBaseUri = "https://api.postmarkapp.com", ISimpleHttpClient client = null)
+ : base(apiBaseUri, client)
{
_authToken = serverToken;
}
diff --git a/src/Postmark/PostmarkClientBase.cs b/src/Postmark/PostmarkClientBase.cs
index b5c4761..cc93c2e 100644
--- a/src/Postmark/PostmarkClientBase.cs
+++ b/src/Postmark/PostmarkClientBase.cs
@@ -14,19 +14,6 @@ namespace PostmarkDotNet
///
public abstract class PostmarkClientBase
{
- private static Lazy _staticClient =
- new Lazy(()=>new SimpleHttpClient()) ;
-
- ///
- /// Configure a global connection factory to to process HTTP interactions.
- ///
- ///
- /// In most cases, you should not need to modify this property, but it's useful
- /// in cases where you want to use another http client, or to mock the http processing
- /// (for tests).
- ///
- public static Func ClientFactory {get;set;} = () => _staticClient.Value;
-
protected static readonly string DATE_FORMAT = "yyyy-MM-dd";
///
@@ -38,15 +25,17 @@ public abstract class PostmarkClientBase
typeof(PostmarkClient).AssemblyQualifiedName + ")";
private Uri baseUri;
+ private readonly ISimpleHttpClient client;
///
/// Provides a base implementation of core request/response interactions.
///
///
- ///
- public PostmarkClientBase(string apiBaseUri = "https://api.postmarkapp.com")
+ /// to processes HTTP interactions.
+ public PostmarkClientBase(string apiBaseUri = "https://api.postmarkapp.com", ISimpleHttpClient client = null)
{
baseUri = new Uri(apiBaseUri);
+ this.client = client ?? new SimpleHttpClient();
}
protected abstract string AuthHeaderName { get; }
@@ -68,8 +57,6 @@ protected async Task ProcessRequestAsync(str
{
TResponse retval = default(TResponse);
- var client = ClientFactory();
-
var request = new HttpRequestMessage(verb, baseUri + apiPath.TrimStart('/'));
//if the message is not a string, or the message is a non-empty string,