Esempio n. 1
0
        public static async Task <HttpClientResult <T> > SendRequestAsync <T>(
            this HttpClient httpClient, HttpRequest request,
            ClientConfig clientConfig, string path, HttpMethod method,
            object data = null, CurrentProcess process = null)
        {
            var response = await _sendRequestAsync(httpClient, request, clientConfig, path, method, data, process).ConfigureAwait(false);

            if (response != null)
            {
                var result = JsonConvert.DeserializeObject <T>(response.Item2);

                if (result is ResponseJsonModel)
                {
                    var obj = result as ResponseJsonModel;

                    if (obj?.error?.code != null)
                    {
                        obj.error.message = "error";
                    }
                }

                return(HttpClientResult <T> .Create(response.Item1, result, response.Item3, response.Item4));
            }
            else
            {
                return(HttpClientResult <T> .Create(response.Item1, TypeExtensions.GetDefaultValue <T>(), null, false));
            }
        }
Esempio n. 2
0
        public static async Task <HttpClientResult <string> > SendRequestAsync(
            this HttpClient httpClient, HttpRequest request,
            ClientConfig clientConfig, string path, HttpMethod method,
            object data = null, CurrentProcess process = null)
        {
            var result = await _sendRequestAsync(httpClient, request, clientConfig, path, method, data, process).ConfigureAwait(false);

            return(result != null
                ? HttpClientResult <string> .Create(result.Item1, result.Item2, result.Item3, result.Item4)
                : HttpClientResult <string> .Create(result.Item1, string.Empty, null, false));
        }