1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 03:52:57 +08:00
osu-lazer/osu.Game/Online/API/Requests/GetCommentsRequest.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

55 lines
1.7 KiB
C#
Raw Normal View History

2019-10-07 21:48:05 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2019-10-07 21:48:05 +08:00
using osu.Framework.IO.Network;
using Humanizer;
using osu.Game.Online.API.Requests.Responses;
2019-10-10 16:43:45 +08:00
using osu.Game.Overlays.Comments;
2019-10-07 21:48:05 +08:00
namespace osu.Game.Online.API.Requests
{
2019-10-15 16:20:06 +08:00
public class GetCommentsRequest : APIRequest<CommentBundle>
2019-10-07 21:48:05 +08:00
{
2020-02-21 17:42:11 +08:00
private readonly long commentableId;
2019-10-07 21:48:05 +08:00
private readonly CommentableType type;
2019-10-13 16:23:49 +08:00
private readonly CommentsSortCriteria sort;
2020-02-21 17:42:11 +08:00
private readonly int page;
private readonly long? parentId;
2019-10-07 21:48:05 +08:00
2020-02-21 17:42:11 +08:00
public GetCommentsRequest(long commentableId, CommentableType type, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1, long? parentId = null)
2019-10-07 21:48:05 +08:00
{
2020-02-21 17:42:11 +08:00
this.commentableId = commentableId;
2019-10-07 21:48:05 +08:00
this.type = type;
this.sort = sort;
this.page = page;
2020-02-21 17:42:11 +08:00
this.parentId = parentId;
2019-10-07 21:48:05 +08:00
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
2020-02-21 17:42:11 +08:00
req.AddParameter("commentable_id", commentableId.ToString());
2019-10-07 21:48:05 +08:00
req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
req.AddParameter("page", page.ToString());
2020-02-21 17:42:11 +08:00
req.AddParameter("sort", sort.ToString().ToLowerInvariant());
if (parentId != null)
req.AddParameter("parent_id", parentId.ToString());
2019-10-07 21:48:05 +08:00
return req;
}
protected override string Target => "comments";
}
public enum CommentableType
{
Build,
Beatmapset,
NewsPost
}
}