2020-06-08 16:49:45 +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.Linq;
|
|
|
|
using System.Net.Http;
|
|
|
|
using osu.Framework.IO.Network;
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
|
|
|
|
namespace osu.Game.Online.API.Requests
|
|
|
|
{
|
|
|
|
public class CreateChannelRequest : APIRequest<APIChatChannel>
|
|
|
|
{
|
2021-06-05 20:42:16 +08:00
|
|
|
public readonly Channel Channel;
|
2020-06-08 16:49:45 +08:00
|
|
|
|
|
|
|
public CreateChannelRequest(Channel channel)
|
|
|
|
{
|
2021-06-05 20:42:16 +08:00
|
|
|
Channel = channel;
|
2020-06-08 16:49:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
{
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
req.Method = HttpMethod.Post;
|
|
|
|
|
|
|
|
req.AddParameter("type", $"{ChannelType.PM}");
|
2021-06-05 20:42:16 +08:00
|
|
|
req.AddParameter("target_id", $"{Channel.Users.First().Id}");
|
2020-06-08 16:49:45 +08:00
|
|
|
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override string Target => @"chat/channels";
|
|
|
|
}
|
|
|
|
}
|