Пример #1
0
        public async Task <ServerResponse <string> > ObtainCsvTransactionsAsync(TransactionQuery query)
        {
            // Sign request
            var signedClientRequest = SignClientRequest(query);

            // Signed request to ByteArrayContent
            var byteContent = SignByteArrayContent(signedClientRequest);

            ServerSignedResponse <string> signedServerResponse;

            // Post async signed request as ByteArrayContent
            using (var request = new HttpRequestMessage(HttpMethod.Post, "Transactions/CSV"))
            {
                request.Content = byteContent;

                var response = await _httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);

                response.EnsureSuccessStatusCode();

                using (var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false))
                    using (var streamReader = new StreamReader(stream))
                        using (var jsonReader = new JsonTextReader(streamReader))
                        {
                            var serializer = new JsonSerializer();

                            // Read the response content from a stream
                            signedServerResponse = serializer.Deserialize <ServerSignedResponse <string> >(jsonReader);
                        }
            }

            return(await UnwrapResponseAsync(signedServerResponse).ConfigureAwait(false));
        }
Пример #2
0
        public async Task <ServerResponse <TransactionCursor> > ObtainTransactionsAsync(TransactionQuery query)
        {
            // Sign request
            var signedClientRequest = SignClientRequest(query);

            // Signed request to ByteArrayContent
            var byteContent = SignByteArrayContent(signedClientRequest);

            // Post async signed request as ByteArrayContent
            var response = await _httpClient.PostAsync("Transactions", byteContent).ConfigureAwait(false);

            response.EnsureSuccessStatusCode();

            var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var signedServerResponse = JsonConvert.DeserializeObject <ServerSignedResponse <TransactionCursor> >(result);

            return(await UnwrapResponseAsync(signedServerResponse).ConfigureAwait(false));
        }