@@ -31,8 +31,6 @@ namespace SocketLabs.InjectionApi
3131 /// </example>
3232 public class SocketLabsClient : ISocketLabsClient , IDisposable
3333 {
34-
35-
3634 private string UserAgent { get ; } = $ "SocketLabs-csharp/{ typeof ( SocketLabsClient ) . GetTypeInfo ( ) . Assembly . GetName ( ) . Version } ";
3735
3836 private readonly int _serverId ;
@@ -45,12 +43,10 @@ public class SocketLabsClient : ISocketLabsClient, IDisposable
4543 public string EndpointUrl { get ; set ; } = "https://inject.socketlabs.com/api/v1/email" ;
4644
4745 /// <summary>
48- /// A timeout occurred sending the message
46+ /// A timeout period for the Injection API request (in Seconds). Default: 120s
4947 /// </summary>
5048 public int RequestTimeout { get ; set ; } = 120 ;
51-
52-
53-
49+
5450 /// <summary>
5551 /// Creates a new instance of the <c>SocketLabsClient</c>.
5652 /// </summary>
@@ -62,8 +58,7 @@ public SocketLabsClient(int serverId, string apiKey)
6258 _apiKey = apiKey ;
6359 _httpClient = BuildHttpClient ( null ) ;
6460 }
65-
66-
61+
6762 /// <summary>
6863 /// Creates a new instance of the <c>SocketLabsClient</c> with a proxy.
6964 /// </summary>
@@ -76,7 +71,7 @@ public SocketLabsClient(int serverId, string apiKey, IWebProxy optionalProxy)
7671 _apiKey = apiKey ;
7772 _httpClient = BuildHttpClient ( optionalProxy ) ;
7873
79- }
74+ }
8075
8176 /// <summary>
8277 /// Creates a new instance of the <c>SocketLabsClient</c> with a provided HttpClient.
@@ -96,7 +91,6 @@ public SocketLabsClient(int serverId, string apiKey, HttpClient httpClient)
9691 private HttpClient BuildHttpClient ( IWebProxy optionalProxy )
9792 {
9893 var httpClient = optionalProxy != null ? new HttpClient ( new HttpClientHandler ( ) { UseProxy = true , Proxy = optionalProxy } ) : new HttpClient ( ) ;
99-
10094 ConfigureHttpClient ( httpClient ) ;
10195 return httpClient ;
10296 }
@@ -228,18 +222,18 @@ public async Task<SendResponse> SendAsync(IBasicMessage message)
228222
229223 var validationResult = validator . ValidateCredentials ( _serverId , _apiKey ) ;
230224 if ( validationResult . Result != SendResult . Success ) return validationResult ;
231-
232-
225+
233226 validationResult = validator . ValidateMessage ( message ) ;
234227 if ( validationResult . Result != SendResult . Success ) return validationResult ;
235228
236229 var factory = new InjectionRequestFactory ( _serverId , _apiKey ) ;
237230 var injectionRequest = factory . GenerateRequest ( message ) ;
238231 var json = injectionRequest . GetAsJson ( ) ;
232+
239233 _httpClient . Timeout = TimeSpan . FromSeconds ( RequestTimeout ) ;
240234 var httpResponse = await _httpClient . PostAsync ( EndpointUrl , json ) ;
241- var response = new InjectionResponseParser ( ) . Parse ( httpResponse ) ;
242235
236+ var response = new InjectionResponseParser ( ) . Parse ( httpResponse ) ;
243237 return response ;
244238 }
245239
@@ -286,8 +280,10 @@ public async Task<SendResponse> SendAsync(IBulkMessage message)
286280
287281 var factory = new InjectionRequestFactory ( _serverId , _apiKey ) ;
288282 var injectionRequest = factory . GenerateRequest ( message ) ;
283+
289284 _httpClient . Timeout = TimeSpan . FromSeconds ( RequestTimeout ) ;
290285 var httpResponse = await _httpClient . PostAsync ( EndpointUrl , injectionRequest . GetAsJson ( ) ) ;
286+
291287 var response = new InjectionResponseParser ( ) . Parse ( httpResponse ) ;
292288 return response ;
293289 }
0 commit comments