2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 18:49:34 +08:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2017-05-18 01:43:11 +08:00
|
|
|
|
using System.Linq;
|
2016-08-31 18:49:34 +08:00
|
|
|
|
using osu.Framework.IO.Network;
|
2016-08-31 19:16:05 +08:00
|
|
|
|
using osu.Game.Online.Chat;
|
2016-08-31 18:49:34 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.API.Requests
|
|
|
|
|
{
|
2016-09-27 17:31:36 +08:00
|
|
|
|
public class GetMessagesRequest : APIRequest<List<Message>>
|
2016-08-31 18:49:34 +08:00
|
|
|
|
{
|
2017-03-23 12:41:50 +08:00
|
|
|
|
private readonly List<Channel> channels;
|
2017-03-07 09:59:19 +08:00
|
|
|
|
private long? since;
|
2016-08-31 18:49:34 +08:00
|
|
|
|
|
|
|
|
|
public GetMessagesRequest(List<Channel> channels, long? sinceId)
|
|
|
|
|
{
|
|
|
|
|
this.channels = channels;
|
2017-02-09 21:18:08 +08:00
|
|
|
|
since = sinceId;
|
2016-08-31 18:49:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
|
{
|
2017-05-18 01:43:11 +08:00
|
|
|
|
string channelString = string.Join(",", channels.Select(x => x.Id));
|
2016-08-31 18:49:34 +08:00
|
|
|
|
|
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
|
req.AddParameter(@"channels", channelString);
|
|
|
|
|
if (since.HasValue) req.AddParameter(@"since", since.Value.ToString());
|
|
|
|
|
|
|
|
|
|
return req;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string Target => @"chat/messages";
|
|
|
|
|
}
|
|
|
|
|
}
|