Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public SendResponse RunExample()
var client = new SocketLabsClient(ExampleConfig.ServerId, ExampleConfig.ApiKey, proxy)
{
EndpointUrl = ExampleConfig.TargetApi,
RequestTimeout = 120,
NumberOfRetries = 3
};

Expand Down
2 changes: 1 addition & 1 deletion src/SocketLabs/InjectionApi/Core/RetryHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task<HttpResponseMessage> SendAsync(StringContent content, Cancella
{
var response = await HttpClient.PostAsync(EndpointUrl, content, cancellationToken)
.ConfigureAwait(false);

if (ErrorStatusCodes.Contains(response.StatusCode))
throw new HttpRequestException(
$"HttpStatusCode: '{response.StatusCode}'. Response contains server error.");
Expand Down
15 changes: 3 additions & 12 deletions src/SocketLabs/InjectionApi/SocketLabsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,7 @@ public class SocketLabsClient : ISocketLabsClient, IDisposable
/// The SocketLabs Injection API endpoint Url
/// </summary>
public string EndpointUrl { get; set; } = "https://inject.socketlabs.com/api/v1/email";

/// <summary>
/// A timeout period for the Injection API request (in Seconds). Default: 120s
/// </summary>
public int RequestTimeout { get; set; } = 120;


/// <summary>
/// RetrySettings object to define retry setting for the Injection API request.
/// </summary>
Expand Down Expand Up @@ -237,9 +232,7 @@ public async Task<SendResponse> SendAsync(IBasicMessage message, CancellationTok
var factory = new InjectionRequestFactory(_serverId, _apiKey);
var injectionRequest = factory.GenerateRequest(message);
var json = injectionRequest.GetAsJson();

_httpClient.Timeout = TimeSpan.FromSeconds(RequestTimeout);


var retryHandler = new RetryHandler(_httpClient, EndpointUrl, new RetrySettings(NumberOfRetries));
var httpResponse = await retryHandler.SendAsync(json, cancellationToken);

Expand Down Expand Up @@ -292,9 +285,7 @@ public async Task<SendResponse> SendAsync(IBulkMessage message, CancellationToke
var factory = new InjectionRequestFactory(_serverId, _apiKey);
var injectionRequest = factory.GenerateRequest(message);
var json = injectionRequest.GetAsJson();

_httpClient.Timeout = TimeSpan.FromSeconds(RequestTimeout);


var retryHandler = new RetryHandler(_httpClient, EndpointUrl, new RetrySettings(NumberOfRetries));
var httpResponse = await retryHandler.SendAsync(json, cancellationToken);

Expand Down