Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> Delete(
            string requestUri, string bearerToken)
        {
            var builder = new HttpRequestBuilder()
                          .AddMethod(HttpMethod.Delete)
                          .AddRequestUri(requestUri)
                          .AddBearerToken(bearerToken);

            this.Request = requestUri;
            var stopWatch = Stopwatch.StartNew();

            var result = await builder.SendAsync();

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

            return(result);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }