1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:42:54 +08:00
osu-lazer/osu.Game/Online/API/Requests/GetCommentsRequest.cs

48 lines
1.4 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.
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
{
private readonly long id;
private readonly int page;
private readonly CommentableType type;
2019-10-13 16:23:49 +08:00
private readonly CommentsSortCriteria sort;
2019-10-07 21:48:05 +08:00
2019-10-13 16:23:49 +08:00
public GetCommentsRequest(CommentableType type, long id, CommentsSortCriteria sort = CommentsSortCriteria.New, int page = 1)
2019-10-07 21:48:05 +08:00
{
this.type = type;
this.sort = sort;
this.id = id;
this.page = page;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.AddParameter("commentable_type", type.ToString().Underscore().ToLowerInvariant());
req.AddParameter("commentable_id", id.ToString());
2019-10-09 03:46:42 +08:00
req.AddParameter("sort", sort.ToString().ToLowerInvariant());
2019-10-07 21:48:05 +08:00
req.AddParameter("page", page.ToString());
return req;
}
protected override string Target => "comments";
}
public enum CommentableType
{
Build,
Beatmapset,
NewsPost
}
}