Пример #1
0
        /// <summary>
        /// Ping a user data stream to prevent a time out.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="apiKey"></param>
        /// <param name="listenKey"></param>
        /// <param name="token"></param>
        /// <returns></returns>
        public static async Task <string> UserStreamKeepAliveAsync(this IKucoinHttpClient client, string apiKey, string listenKey, CancellationToken token = default)
        {
            Throw.IfNullOrWhiteSpace(apiKey, nameof(apiKey));
            Throw.IfNullOrWhiteSpace(listenKey, nameof(listenKey));

            if (client.RateLimiter != null)
            {
                await client.RateLimiter.DelayAsync(token : token)
                .ConfigureAwait(false);
            }

            var request = new KucoinHttpRequest("/api/v1/userDataStream")
            {
                ApiKey = apiKey
            };

            request.AddParameter("listenKey", listenKey);

            // TODO
            // A POST will either get back your current stream (and effectively do a PUT) or get back a new stream.
            //return await client.PostAsync(request, token)
            return(await client.PutAsync(request, token)
                   .ConfigureAwait(false));
        }