mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 07:22:55 +08:00
Add submission requests
This commit is contained in:
parent
aeff9bd853
commit
5267fb74c4
32
osu.Game/Online/Solo/CreateSoloScoreRequest.cs
Normal file
32
osu.Game/Online/Solo/CreateSoloScoreRequest.cs
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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.Net.Http;
|
||||||
|
using osu.Framework.IO.Network;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Solo
|
||||||
|
{
|
||||||
|
public class CreateSoloScoreRequest : APIRequest<APIScoreToken>
|
||||||
|
{
|
||||||
|
private readonly int beatmapId;
|
||||||
|
private readonly string versionHash;
|
||||||
|
|
||||||
|
public CreateSoloScoreRequest(int beatmapId, string versionHash)
|
||||||
|
{
|
||||||
|
this.beatmapId = beatmapId;
|
||||||
|
this.versionHash = versionHash;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WebRequest CreateWebRequest()
|
||||||
|
{
|
||||||
|
var req = base.CreateWebRequest();
|
||||||
|
req.Method = HttpMethod.Post;
|
||||||
|
req.AddParameter("version_hash", versionHash);
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"solo/{beatmapId}/scores";
|
||||||
|
}
|
||||||
|
}
|
45
osu.Game/Online/Solo/SubmitSoloScoreRequest.cs
Normal file
45
osu.Game/Online/Solo/SubmitSoloScoreRequest.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
// 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.Net.Http;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using osu.Framework.IO.Network;
|
||||||
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
|
namespace osu.Game.Online.Solo
|
||||||
|
{
|
||||||
|
public class SubmitSoloScoreRequest : APIRequest<MultiplayerScore>
|
||||||
|
{
|
||||||
|
private readonly long scoreId;
|
||||||
|
|
||||||
|
private readonly int beatmapId;
|
||||||
|
|
||||||
|
private readonly ScoreInfo scoreInfo;
|
||||||
|
|
||||||
|
public SubmitSoloScoreRequest(int beatmapId, long scoreId, ScoreInfo scoreInfo)
|
||||||
|
{
|
||||||
|
this.beatmapId = beatmapId;
|
||||||
|
this.scoreId = scoreId;
|
||||||
|
this.scoreInfo = scoreInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override WebRequest CreateWebRequest()
|
||||||
|
{
|
||||||
|
var req = base.CreateWebRequest();
|
||||||
|
|
||||||
|
req.ContentType = "application/json";
|
||||||
|
req.Method = HttpMethod.Put;
|
||||||
|
|
||||||
|
req.AddRaw(JsonConvert.SerializeObject(scoreInfo, new JsonSerializerSettings
|
||||||
|
{
|
||||||
|
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||||
|
}));
|
||||||
|
|
||||||
|
return req;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string Target => $@"solo/{beatmapId}/scores/{scoreId}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user