2019-01-24 17:43:03 +09: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.
|
2018-12-22 12:50:37 +09:00
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-07-10 17:26:42 +09:00
|
|
|
|
using osu.Framework.IO.Network;
|
2022-06-20 15:02:15 +02:00
|
|
|
|
using osu.Game.Extensions;
|
2020-07-22 18:29:50 +09:00
|
|
|
|
using osu.Game.Online.API;
|
2020-12-25 16:50:00 +01:00
|
|
|
|
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
2018-12-22 12:50:37 +09:00
|
|
|
|
|
2020-12-25 13:38:11 +09:00
|
|
|
|
namespace osu.Game.Online.Rooms
|
2018-12-22 12:50:37 +09:00
|
|
|
|
{
|
|
|
|
|
public class GetRoomsRequest : APIRequest<List<Room>>
|
|
|
|
|
{
|
2024-12-11 12:36:42 +09:00
|
|
|
|
private readonly RoomModeFilter mode;
|
2024-12-11 13:01:11 +09:00
|
|
|
|
private readonly RoomStatusFilter? status;
|
2020-12-07 21:59:38 +09:00
|
|
|
|
private readonly string category;
|
2018-12-22 12:50:37 +09:00
|
|
|
|
|
2024-12-11 13:01:11 +09:00
|
|
|
|
public GetRoomsRequest(FilterCriteria filterCriteria)
|
2018-12-22 12:50:37 +09:00
|
|
|
|
{
|
2024-12-11 13:01:11 +09:00
|
|
|
|
mode = filterCriteria.Mode;
|
|
|
|
|
category = filterCriteria.Category;
|
|
|
|
|
status = filterCriteria.Status;
|
2018-12-22 12:50:37 +09:00
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 17:26:42 +09:00
|
|
|
|
protected override WebRequest CreateWebRequest()
|
2018-12-22 12:50:37 +09:00
|
|
|
|
{
|
2020-07-10 17:26:42 +09:00
|
|
|
|
var req = base.CreateWebRequest();
|
2019-04-01 12:44:46 +09:00
|
|
|
|
|
2024-12-11 12:36:42 +09:00
|
|
|
|
if (mode != RoomModeFilter.Open)
|
2024-12-11 13:01:11 +09:00
|
|
|
|
req.AddParameter(@"mode", mode.ToString().ToSnakeCase().ToLowerInvariant());
|
|
|
|
|
|
|
|
|
|
if (status != null)
|
|
|
|
|
req.AddParameter(@"status", status.Value.ToString().ToSnakeCase().ToLowerInvariant());
|
2020-07-10 19:54:09 +09:00
|
|
|
|
|
2020-12-07 21:59:38 +09:00
|
|
|
|
if (!string.IsNullOrEmpty(category))
|
2024-12-11 13:01:11 +09:00
|
|
|
|
req.AddParameter(@"category", category);
|
2020-07-10 17:26:42 +09:00
|
|
|
|
|
|
|
|
|
return req;
|
2018-12-22 12:50:37 +09:00
|
|
|
|
}
|
2020-07-10 17:26:42 +09:00
|
|
|
|
|
2024-12-11 13:01:11 +09:00
|
|
|
|
protected override string Target => @"rooms";
|
2018-12-22 12:50:37 +09:00
|
|
|
|
}
|
|
|
|
|
}
|