Esempio n. 1
0
        public virtual async Task <string> DoExecute <T>(ApiRequest <T> request)
            where T : ApiResponse
        {
            try
            {
                var             url    = $"{_options.ApiUrl.TrimEnd('/')}{request.GetUrl()}";
                var             result = String.Empty;
                HttpAbstraction http   = _factory.CreateHttp(request.Method);


                if (request.Method == HttpRequestActionType.Get)
                {
                    return(await http.Setup()
                           .SetUrl(url)
                           .GetResponseAsync());
                }

                return(await http.Setup()
                       .SetUrl(url)
                       .SetContent(request.GetPostContent())
                       .GetResponseAsync());
            }
            catch (Exception ex)
            {
                throw new WXApiException(WXErrorCode.GetResponseFaild, $"get response is faild, method is :{request.GetType().FullName}", ex);
            }
        }