osu/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 13:48:05 +00: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 07:37:17 +00:00
#nullable disable
2019-10-07 13:48:05 +00:00
using osu.Framework.IO.Network;
using Humanizer;
using osu.Game.Online.API.Requests.Responses;
2019-10-10 08:43:45 +00:00
using osu.Game.Overlays.Comments;
2019-10-07 13:48:05 +00:00
namespace osu.Game.Online.API.Requests
{
2019-10-15 08:20:06 +00:00
public class GetCommentsRequest : APIRequest<CommentBundle>
2019-10-07 13:48:05 +00:00
{
2020-02-21 09:42:11 +00:00
private readonly long commentableId;
2019-10-07 13:48:05 +00:00
private readonly CommentableType type;
2019-10-13 08:23:49 +00:00
private readonly CommentsSortCriteria sort;
2020-02-21 09:42:11 +00:00
private readonly int page;
private readonly long? parentId;
2019-10-07 13:48:05 +00:00
2020-02-21 09:42:11 +00:00
public GetCommentsRequest(long commentableId, CommentableType type, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1, long? parentId = null)
2019-10-07 13:48:05 +00:00
{
2020-02-21 09:42:11 +00:00
this.commentableId = commentableId;
2019-10-07 13:48:05 +00:00
this.type = type;
this.sort = sort;
this.page = page;
2020-02-21 09:42:11 +00:00
this.parentId = parentId;
2019-10-07 13:48:05 +00:00
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
2020-02-21 09:42:11 +00:00
req.AddParameter("commentable_id", commentableId.ToString());
2019-10-07 13:48:05 +00:00
req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
req.AddParameter("page", page.ToString());
2020-02-21 09:42:11 +00:00
req.AddParameter("sort", sort.ToString().ToLowerInvariant());
if (parentId != null)
req.AddParameter("parent_id", parentId.ToString());
2019-10-07 13:48:05 +00:00
return req;
}
protected override string Target => "comments";
}
public enum CommentableType
{
Build,
Beatmapset,
NewsPost
}
}