private static OsuCommentsRequest GetRequest(OsuCommentsSummary last, uint?limit, Func <OsuCommentsRequest> factory) { if (last?.More == false) { return(null); } var request = factory.Invoke(); request.Limit = limit; request.Cursor = last?.Cursor; return(request); }
/// <summary> /// Get a single comment (and its neighbouring comments?) /// </summary> /// <param name="client">The <see cref="OrbitClient"/> to use</param> /// <param name="commentId">Id of the comment to fetch</param> /// <param name="last">Optional response of the last request for getting the "next page" of results</param> /// <param name="limit">Optional upper-limit for returned responses</param> /// <returns> /// Comments summary, including all metadata (users/maps/posts) the comment(s) relate to. /// Returns null if there are no more comments (based on the cursor) /// </returns> public static Task <OsuCommentsSummary> GetComment(this OrbitClient client, uint commentId, OsuCommentsSummary last = null, uint?limit = null) { var request = GetRequest(last, limit, () => new OsuCommentsRequest(commentId, false)); return(request is null ? null : client.PerformAsync <OsuCommentsSummary>(request)); }
/// <summary> /// Gets child comments posted in reply to a comment (upto 2 levels deep) /// </summary> /// <param name="client">The <see cref="OrbitClient"/> to use</param> /// <param name="type">The <see cref="CommentableType"/> the <see cref="typeId"/> is</param> /// <param name="typeId">The id of the entity to get comments for</param> /// <param name="last">Optional response of the last request for getting the "next page" of results</param> /// <param name="limit">Optional upper-limit for returned responses</param> /// <returns> /// Comments summary, including all metadata (users/maps/posts) the comments relate to. /// Returns null if there are no more comments (based on the cursor) /// </returns> public static Task <OsuCommentsSummary> GetComments(this OrbitClient client, CommentableType type, uint typeId, OsuCommentsSummary last = null, uint?limit = null) { var request = GetRequest(last, limit, () => new OsuCommentsRequest(type, typeId)); return(request is null ? null : client.PerformAsync <OsuCommentsSummary>(request)); }