public WebCaller(Client client = null, Serializer serializer = null, Logger logger = null, ClientSetting clientSetting = null, object serializerSettings = null, Type errorPayloadType = null, ErrorPayloadTypeSelector errorPayloadTypeSelector = null) { _client = client; _serializer = serializer; _logger = logger; new ClientSettingsValidator().Validate(clientSetting); _clientSetting = clientSetting; _serializerSettings = serializerSettings; _errorPayloadType = errorPayloadType; _errorPayloadTypeSelector = errorPayloadTypeSelector; SetDefaults(); }
private async Task Log(WebClientResponseMessage postResponse, object request, string postRequest, object response, double timeTakenInMiliseconds, ClientSetting clientSetting, string url, DateTime startTimestamp) { try { if (_logger != null) { var strResponse = string.Empty; if (postResponse?.Data != null) { strResponse = clientSetting.Encoding.GetString(postResponse.Data); } await _logger.RaiseLogEvent(request, response, postRequest, strResponse, timeTakenInMiliseconds / 1000, postResponse, clientSetting.Headers, url, startTimestamp); } } catch (Exception exception) { throw new LoggingException("Exception occurred at the time of logging", exception); } }
public override Task <WebClientResponseMessage> GetAsync(WebClientRequestMessage request, ClientSetting clientSetting, CancellationToken cancellationToken) { var client = WebClientFactory.Create(new Settings() { TimeOut = (int)clientSetting.TimeOut.TotalMilliseconds }); return(client.GetAsync(request, cancellationToken)); }
public abstract Task <WebClientResponseMessage> GetAsync(WebClientRequestMessage request, ClientSetting clientSetting, CancellationToken cancellationToken);
public override Task <WebClientResponseMessage> PatchAsync(WebClientRequestMessage request, ClientSetting clientSetting, CancellationToken cancellationToken) { throw new NotImplementedException(); }