2018-01-05 11:21:19 +00:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 04:59:30 +00:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-08-31 10:49:34 +00:00
|
|
|
|
|
2018-04-11 18:01:57 +00:00
|
|
|
|
using System;
|
2016-08-31 10:49:34 +00:00
|
|
|
|
using System.Collections.Generic;
|
2017-05-17 17:43:11 +00:00
|
|
|
|
using System.Linq;
|
2016-08-31 10:49:34 +00:00
|
|
|
|
using osu.Framework.IO.Network;
|
2016-08-31 11:16:05 +00:00
|
|
|
|
using osu.Game.Online.Chat;
|
2016-08-31 10:49:34 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Online.API.Requests
|
|
|
|
|
{
|
2018-04-14 11:23:16 +00:00
|
|
|
|
public class GetMessagesRequest : APIMessagesRequest
|
2016-08-31 10:49:34 +00:00
|
|
|
|
{
|
2018-04-11 18:01:57 +00:00
|
|
|
|
private readonly IEnumerable<Channel> channels;
|
2016-08-31 10:49:34 +00:00
|
|
|
|
|
2018-04-14 11:23:16 +00:00
|
|
|
|
public GetMessagesRequest(IEnumerable<Channel> channels, long? sinceId) : base(sinceId)
|
2016-08-31 10:49:34 +00:00
|
|
|
|
{
|
2018-04-11 18:01:57 +00:00
|
|
|
|
if (channels == null)
|
|
|
|
|
throw new ArgumentNullException(nameof(channels));
|
|
|
|
|
if (channels.Any(c => c.Target != TargetType.Channel))
|
|
|
|
|
throw new ArgumentException("All channels in the argument channels must have the targettype Channel");
|
|
|
|
|
|
2016-08-31 10:49:34 +00:00
|
|
|
|
this.channels = channels;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override WebRequest CreateWebRequest()
|
|
|
|
|
{
|
2017-05-17 17:43:11 +00:00
|
|
|
|
string channelString = string.Join(",", channels.Select(x => x.Id));
|
2016-08-31 10:49:34 +00:00
|
|
|
|
|
|
|
|
|
var req = base.CreateWebRequest();
|
|
|
|
|
req.AddParameter(@"channels", channelString);
|
|
|
|
|
|
|
|
|
|
return req;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override string Target => @"chat/messages";
|
|
|
|
|
}
|
2018-01-05 11:21:19 +00:00
|
|
|
|
}
|