Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="restConnection">The rest connection.</param>
        /// <returns>Task&lt;RestResponse&gt;.</returns>
        /// <summary>
        /// Executes the specified request.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <param name="restConnection">The rest connection.</param>
        /// <returns>Task&lt;RestResponse&gt;.</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);
        }
Exemplo n.º 3
0
        /// <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&lt;RestResponse&lt;T&gt;&gt;.</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&lt;RestResponse&lt;T&gt;&gt;.</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);
        }
Exemplo n.º 4
0
        /// <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&lt;RestResponse&lt;T&gt;&gt;.</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&lt;RestResponse&lt;T&gt;&gt;.</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);
        }