public RestResponse ExecuteSync(RestRequest request, IRestConnection restConnection) { var client = BuildRestClientSync(restConnection); var restRequest = _mapper.Map <RestSharpRestRequest>(request); var restResponse = client.Execute(restRequest); var response = _mapper.Map <Rest.RestResponse>(restResponse); NormalizeErrorsToExceptions(restResponse, response); return(response); }
/// <summary> /// Executes the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse>.</returns> /// <summary> /// Executes the specified request. /// </summary> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse>.</returns> public async Task <RestResponse> Execute(RestRequest request, IRestConnection restConnection) { var client = await BuildRestClient(restConnection); var restRequest = _mapper.Map <RestSharpRestRequest>(request); var restResponse = await client.ExecuteTaskAsync(restRequest); var response = _mapper.Map <Rest.RestResponse>(restResponse); NormalizeErrorsToExceptions(restResponse, response); return(response); }
/// <summary> /// Executes the specified request. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse<T>>.</returns> /// <summary> /// Executes the specified request. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse<T>>.</returns> public async Task <Rest.RestResponse <T> > Execute <T>(RestRequest request, IRestConnection restConnection) { var client = await BuildRestClient(restConnection); var restRequest = _mapper.Map <RestSharpRestRequest>(request); // // make the REST request and wait for the response // var restResponse = await client.ExecuteTaskAsync <T>(restRequest); var response = _mapper.Map <Rest.RestResponse <T> >(restResponse); NormalizeErrorsToExceptions(restResponse, response); return(response); }
/// <summary> /// Executes the specified request. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse<T>>.</returns> /// <summary> /// Executes the specified request. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="request">The request.</param> /// <param name="restConnection">The rest connection.</param> /// <returns>Task<RestResponse<T>>.</returns> public Rest.RestResponse <T> ExecuteSync <T>(RestRequest request, IRestConnection restConnection) where T : class, new() { var client = BuildRestClientSync(restConnection); var restRequest = _mapper.Map <RestSharpRestRequest>(request); // // make the REST request and wait for the response // var restResponse = client.Execute <T>(restRequest, (Method)Enum.Parse(typeof(Method), request.Method.ToString())); var response = _mapper.Map <Rest.RestResponse <T> >(restResponse); NormalizeErrorsToExceptions(restResponse, response); return(response); }