public async Task <T> PostData <T>(string command, string relativeUrl, Dictionary <string, string> postData)
        {
            if (authenticator == null)
            {
                throw new Exception("Cannot use the private api without Authenticator set");
            }

            // add command and nonce
            postData.Add("command", command);
            postData.Add("nonce", NonceCalculator.GetCurrentHttpPostNonce());

            var content = new FormUrlEncodedContent(postData);
            var request = new HttpRequestMessage(HttpMethod.Post, BaseUrl + relativeUrl)
            {
                Content = content,
            };

            // sign the content, using the credentials stored in the Authenticator
            var contentBytes = await content.ReadAsByteArrayAsync();

            authenticator.SignRequest(request, contentBytes);

            var response = await innerClient.SendAsync(request);

            var responseObject = await DeserializeResponseJson <T>(response);

            return(responseObject);
        }
示例#2
0
        // return type will fail: needs to parse out the JArray and return a new type of collection
        public Task <IEnumerable <Trade> > GetTrades(DateTime startTime, DateTime endTime)
        {
            var postData = new Dictionary <string, string> {
                { "currencyPair", "ALL" },
                { "start", NonceCalculator.DateTimeToUnixTimeStamp(startTime).ToString() },
                { "end", NonceCalculator.DateTimeToUnixTimeStamp(endTime).ToString() }
            };

            return(ApiHttpClient.PostData <IEnumerable <Trade> >("returnTradeHistory", ApiUrlHttpsRelativeTrading, postData));
        }