private static void PreSendRequest <T>(FactuurSturenClient factuurSturenClient, RestRequest restRequest, bool byPassCheckInitialized) where T : class { if (factuurSturenClient == null) { throw new ArgumentNullException(nameof(factuurSturenClient)); } if (!byPassCheckInitialized) { factuurSturenClient.CheckInitialized(); } restRequest.ContentType = ContentTypes.Json; restRequest.AddHeader("Accept", "application/json"); }
internal static async Task <RestResponse <T> > SendWithPolicyAsync <T>(this RestClient restClient, FactuurSturenClient factuurSturenClient, RestRequest restRequest, CancellationToken cancellationToken = default(CancellationToken), bool retryHttpPostAndPut = true, bool byPassCheckInitialized = false) where T : class { PreSendRequest <T>(factuurSturenClient, restRequest, byPassCheckInitialized); if (!factuurSturenClient.UsePollyTransientFaultHandling) { return(await restClient.SendAsync <T>(restRequest, cancellationToken)); } try { var retVal = await SendRequestWithPolicy <T>(restClient, restRequest, cancellationToken); return(retVal); } catch (Exception e) { throw new RequestFailedLibException("Even with transient fault handling enabled, the request failed.", e); } }