Esempio n. 1
0
        public void ComposeGetRequest()
        {
            RequestOptionsEncrypted options = new RequestOptionsEncrypted(config, HttpMethod.Get, "/my/path");
            var reqMessage = options.ComposeRequestMessage();

            Assert.Equal(HttpMethod.Get, reqMessage.Method);
            Assert.Equal("/base/url/my/path", reqMessage.RequestUri.ToString());
        }
Esempio n. 2
0
        public async void ComposePostRequest()
        {
            RequestOptionsEncrypted options = new RequestOptionsEncrypted(config, HttpMethod.Post, "/my/path", "['prop1': 12, 'prop2': 'abc']");
            var reqMessage = options.ComposeRequestMessage();

            Assert.Equal(HttpMethod.Post, reqMessage.Method);
            Assert.Equal("/base/url/my/path", reqMessage.RequestUri.ToString());
            string content = await reqMessage.Content.ReadAsStringAsync();

            Assert.Equal("['prop1': 12, 'prop2': 'abc']", content);
        }
Esempio n. 3
0
        public async Task <ApiResponse <T> > SendRequest <T>(HttpMethod method, string path, string payload = null)
        {
            RequestOptionsEncrypted requestOptions = new RequestOptionsEncrypted(
                configuration,
                method,
                path,
                payload);
            string content = await _requester.SendAsync(requestOptions);

            return(JsonConvert.DeserializeObject <ApiResponse <T> >(content));
        }