1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Add request class

This commit is contained in:
ansel 2023-01-06 23:31:19 +03:00
parent 387326db0d
commit 768a33bb64

View File

@ -0,0 +1,41 @@
// 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;
public readonly long? ReplyTo;
public CommentPostRequest(CommentableType commentable, long commentableId, string message, long? replyTo = null)
{
Commentable = commentable;
CommentableId = commentableId;
Message = message;
ReplyTo = replyTo;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
req.Method = HttpMethod.Post;
req.AddParameter(@"comment[commentable_type]", Commentable.ToString());
req.AddParameter(@"comment[commentable_id]", $"{CommentableId}");
req.AddParameter(@"comment[message]", Message);
if (ReplyTo.HasValue)
req.AddParameter(@"comment[parent_id]", $"{ReplyTo}");
return req;
}
protected override string Target => "comments";
}
}