Exemplo n.º 1
0
        public async Task <HttpResponseMessage> Post(
            string requestUri, StringContent value, X509Certificate2 certificate)
        {
            var builder = new HttpRequestBuilder()
                          .AddMethod(HttpMethod.Post)
                          .AddRequestUri(requestUri)
                          .AddContent(value)
                          .AddCertificcate(certificate);


            this.Request = await value.ReadAsStringAsync();

            var stopWatch = Stopwatch.StartNew();

            var result = await builder.SendAsync();

            this.ElapsedTime = stopWatch.ElapsedMilliseconds;
            this.Response    = result.ContentAsString();

            return(result);
        }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> Patch(
            string requestUri, object value, string bearerToken)
        {
            var content = new JsonContent(value);
            var builder = new HttpRequestBuilder()
                          .AddMethod(new HttpMethod("PATCH"))
                          .AddRequestUri(requestUri)
                          .AddContent(content)
                          .AddBearerToken(bearerToken);

            this.Request = await content.ReadAsStringAsync();

            var stopWatch = Stopwatch.StartNew();

            var result = await builder.SendAsync();

            this.ElapsedTime = stopWatch.ElapsedMilliseconds;
            this.Response    = result.ContentAsString();

            return(result);
        }
Exemplo n.º 3
0
        public async Task <HttpResponseMessage> PostFile(string requestUri,
                                                         string filePath, string apiParamName, string bearerToken)
        {
            var content = new FileContent(filePath, apiParamName);

            var builder = new HttpRequestBuilder()
                          .AddMethod(HttpMethod.Post)
                          .AddRequestUri(requestUri)
                          .AddContent(content)
                          .AddBearerToken(bearerToken);

            this.Request = await content.ReadAsStringAsync();

            var stopWatch = Stopwatch.StartNew();

            var result = await builder.SendAsync();

            this.ElapsedTime = stopWatch.ElapsedMilliseconds;
            this.Response    = result.ContentAsString();

            return(result);
        }