Пример #1
0
        private StringContent CreateJsonContent(QTRequestModel request)
        {
            var json    = JsonConvert.SerializeObject(request);
            var content = new StringContent(json, Encoding.Default, "application/json");

            return(content);
        }
Пример #2
0
        public async Task <QTResponseModel> SendCommandAsync(string command, params string[] args)
        {
            var request      = new QTRequestModel(command, args);
            var responseText = await SendRequest(request);

            return(JsonConvert.DeserializeObject <QTResponseModel>(responseText));
        }
Пример #3
0
        private async Task <string> SendRequest(QTRequestModel request)
        {
            using (var handler = CreateAuthorizedClientHandler())
                using (var client = new HttpClient(handler))
                {
                    var content = CreateJsonContent(request);
                    var result  = await client.PostAsync(_walletAddress, content);

                    AssertSuccessful(result);

                    return(await result.Content.ReadAsStringAsync());
                }
        }