Exemple #1
0
        public static async Task <RestResponse <T> > Get <T>(IronClientConfig config, string endPoint, NameValueCollection query = null) where T : class
        {
            HttpRequestMessage request = RestUtility.BuildIronRequest(config, new RestClientRequest
            {
                EndPoint = endPoint,
                Query    = query,
                Method   = HttpMethod.Get
            });

            return(new RestResponse <T>(await AttemptRequestAync(config.SharpConfig, request)));
        }
Exemple #2
0
        public static Task <HttpResponseMessage> Execute(IronClientConfig config, IRestClientRequest request)
        {
            HttpRequestMessage httpRequest = RestUtility.BuildIronRequest(config, new RestClientRequest
            {
                EndPoint = request.EndPoint,
                Query    = request.Query,
                Method   = request.Method,
                Content  = request.Content
            });

            using (var client = CreateHttpClient())
            {
                return(client.SendAsync(httpRequest));
            }
        }
Exemple #3
0
        public static async Task <RestResponse <T> > Put <T>(IronClientConfig config, string endPoint, object payload, NameValueCollection query = null) where T : class
        {
            HttpRequestMessage request = RestUtility.BuildIronRequest(config, new RestClientRequest
            {
                EndPoint = endPoint,
                Query    = query,
                Method   = HttpMethod.Put
            });

            IronSharpConfig sharpConfig = config.SharpConfig;

            if (payload != null)
            {
                request.Content = new JsonContent(payload);
            }

            return(new RestResponse <T>(await AttemptRequestAync(sharpConfig, request)));
        }