/// <summary> /// Makes the asynchronous HTTP request. /// </summary> /// <param name="path">URL path.</param> /// <param name="method">HTTP method.</param> /// <returns>The Task instance.</returns> public async System.Threading.Tasks.Task <HttpResponseMessage> CallApiAsync( String path, HttpMethod method, RequestParameters parameters) { var request = PrepareRequest(path, method, parameters); InterceptRequest(request); var res = new InterceptResult(); var response = await RestClient.SendAsync(request); InterceptResponse(request, response, res); if (res.Retry) { request = PrepareRequest(path, method, parameters); //HttpClient requires to create new request message response = await RestClient.SendAsync(request); InterceptResponse(request, response, res); } return(response); }
/// <summary> /// Makes the HTTP request (Sync). /// </summary> /// <param name="path">URL path.</param> /// <param name="method">HTTP method.</param> /// <returns>Object</returns> public HttpResponseMessage CallApi( String path, HttpMethod method, RequestParameters parameters) { var request = PrepareRequest(path, method, parameters); InterceptRequest(request); var res = new InterceptResult(); var response = RestClient.SendAsync(request).Result; InterceptResponse(request, response, res); if (res.Retry) { request = PrepareRequest(path, method, parameters); //HttpClient requires to create new request message response = RestClient.SendAsync(request).Result; InterceptResponse(request, response, res); } return(response); }
/// <summary> /// Allows for extending response processing for <see cref="ApiClient"/> generated code. /// </summary> /// <param name="request">The RestSharp request object</param> /// <param name="response">The RestSharp response object</param> partial void InterceptResponse(HttpRequestMessage request, HttpResponseMessage response, InterceptResult res);