Пример #1
0
        /// <summary>
        /// Make a call to a private (authenticated) API
        /// </summary>
        /// <param name="url">Endpoint to make a request to</param>
        /// <returns>The raw JSON returned from Coins-E</returns>
        private async Task <JObject> CallPrivate(CoinsEMethod method, CoinsEOrderFilter filter,
                                                 string cursor, int?limit, string url)
        {
            List <KeyValuePair <string, string> > kvPairs = new List <KeyValuePair <string, string> >(
                new[] {
                new KeyValuePair <string, string>(PARAM_METHOD, Enum.GetName(method.GetType(), method)),
                new KeyValuePair <string, string>(PARAM_NONCE, GetNextNonce()),
                new KeyValuePair <string, string>(PARAM_FILTER, Enum.GetName(typeof(CoinsEOrderFilter), filter).ToLower())
            }
                );

            if (null != cursor)
            {
                kvPairs.Add(new KeyValuePair <string, string>(PARAM_CURSOR, cursor));
            }
            if (null != limit)
            {
                kvPairs.Add(new KeyValuePair <string, string>(PARAM_LIMIT, limit.ToString()));
            }

            FormUrlEncodedContent request = new FormUrlEncodedContent(kvPairs.ToArray());

            this.SignRequest(request);

            return(await CallPrivate(request, url));
        }
Пример #2
0
        public async Task <List <CoinsEMyOrder> > GetMyOrders(MarketId marketId,
                                                              CoinsEOrderFilter filter, string cursor, int?limit)
        {
            JObject responseJson = await CallPrivate(CoinsEMethod.listorders, filter, cursor, limit, GetMarketUrl(marketId));

            return(responseJson.Value <JArray>("orders").Select(
                       order => CoinsEMyOrder.Parse(order as JObject)
                       ).ToList());
        }