1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 08:34:04 +08:00
osu-lazer/osu.Game/Online/API/Requests/CommentPostRequest.cs

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

42 lines
1.4 KiB
C#
Raw Normal View History

2023-01-07 04:31:19 +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 System.Net.Http;
using osu.Framework.IO.Network;
using osu.Game.Online.API.Requests.Responses;
namespace osu.Game.Online.API.Requests
{
public class CommentPostRequest : APIRequest<CommentBundle>
{
public readonly CommentableType Commentable;
public readonly long CommentableId;
public readonly string Message;
2023-01-15 01:15:19 +08:00
public readonly long? ParentCommentId;
2023-01-07 04:31:19 +08:00
2023-01-15 01:15:19 +08:00
public CommentPostRequest(CommentableType commentable, long commentableId, string message, long? parentCommentId = null)
2023-01-07 04:31:19 +08:00
{
Commentable = commentable;
CommentableId = commentableId;
Message = message;
2023-01-15 01:15:19 +08:00
ParentCommentId = parentCommentId;
2023-01-07 04:31:19 +08:00
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
2023-01-07 07:59:32 +08:00
req.AddParameter(@"comment[commentable_type]", Commentable.ToString().ToLowerInvariant());
2023-01-07 04:31:19 +08:00
req.AddParameter(@"comment[commentable_id]", $"{CommentableId}");
req.AddParameter(@"comment[message]", Message);
2023-01-15 01:15:19 +08:00
if (ParentCommentId.HasValue)
req.AddParameter(@"comment[parent_id]", $"{ParentCommentId}");
2023-01-07 04:31:19 +08:00
return req;
}
protected override string Target => "comments";
}
}