/// <summary> /// put resilient as an asynchronous operation. /// </summary> /// <typeparam name="TResponseType">The type to deserialize the JSON response.</typeparam> /// <typeparam name="TContentType">The content type of the object to be JSON serialized and sent.</typeparam> /// <param name="httpClient">The HTTP client.</param> /// <param name="url">The URL of the host to send the request to.</param> /// <param name="contentObject">The content object to be sent.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="httpContentType"></param> /// <param name="encoding"></param> /// <param name="maxRetries">The maximum retries.</param> /// <param name="retryStatusCodes"></param> /// <returns>Task<T>.</returns> /// <exception cref="ResilientHttpRequestException">There is no HTTP response or the response was not sccessful.</exception> public static async Task <TResponseType> PutResilientAsync <TResponseType, TContentType>(this System.Net.Http.HttpClient httpClient, string url, TContentType contentObject, CancellationToken cancellationToken, string httpContentType = HttpMediaType.Json, Encoding encoding = null, int?maxRetries = null, List <HttpStatusCode> retryStatusCodes = null) where TResponseType : class where TContentType : class { var response = await PutResilientAsync(httpClient, url, contentObject, cancellationToken, httpContentType, encoding, maxRetries, retryStatusCodes); return(await HttpClientExtensions.ProcessResponse <TResponseType>(response, maxRetries)); }
/// <summary> /// get resilient as an asynchronous operation. /// </summary> /// <typeparam name="TResponseType">The type to deserialize the JSON response.</typeparam> /// <param name="httpClient">The HTTP client.</param> /// <param name="url">The URL of the host to send the request to.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <param name="maxRetries">The maximum retries.</param> /// <param name="retryStatusCodes">The retry status codes.</param> /// <returns>Task<TResponseType>.</returns> public static async Task <TResponseType> GetResilientAsync <TResponseType>(this System.Net.Http.HttpClient httpClient, string url, CancellationToken cancellationToken, int?maxRetries = null, List <HttpStatusCode> retryStatusCodes = null) where TResponseType : class { var response = await GetResilientAsync(httpClient, url, cancellationToken, maxRetries, retryStatusCodes); return(await HttpClientExtensions.ProcessResponse <TResponseType>(response, maxRetries)); }