osu/osu.Game/Online/Rooms/GetRoomsRequest.cs

39 lines
1.1 KiB
C#
Raw Normal View History

// 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.Collections.Generic;
2020-07-10 10:54:09 +00:00
using Humanizer;
using osu.Framework.IO.Network;
using osu.Game.Online.API;
using osu.Game.Screens.Multi.Lounge.Components;
2020-12-25 04:38:11 +00:00
namespace osu.Game.Online.Rooms
{
public class GetRoomsRequest : APIRequest<List<Room>>
{
2020-12-07 12:59:38 +00:00
private readonly RoomStatusFilter status;
private readonly string category;
2020-12-07 12:59:38 +00:00
public GetRoomsRequest(RoomStatusFilter status, string category)
{
2020-12-07 12:59:38 +00:00
this.status = status;
this.category = category;
}
protected override WebRequest CreateWebRequest()
{
var req = base.CreateWebRequest();
2019-04-01 03:44:46 +00:00
2020-12-07 12:59:38 +00:00
if (status != RoomStatusFilter.Open)
req.AddParameter("mode", status.ToString().Underscore().ToLowerInvariant());
2020-07-10 10:54:09 +00:00
2020-12-07 12:59:38 +00:00
if (!string.IsNullOrEmpty(category))
req.AddParameter("category", category);
return req;
}
protected override string Target => "rooms";
}
}