mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Standardise and combine base implementation of score submission requests
These share too much yet have very different constructor signatures and property exposure. Just a clean-up pass as I begin to look at replay submission.
This commit is contained in:
@ -1,46 +1,21 @@
|
||||
// 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>
|
||||
public class SubmitSoloScoreRequest : SubmitScoreRequest
|
||||
{
|
||||
public readonly SubmittableScore Score;
|
||||
|
||||
private readonly long scoreId;
|
||||
|
||||
private readonly int beatmapId;
|
||||
|
||||
public SubmitSoloScoreRequest(int beatmapId, long scoreId, ScoreInfo scoreInfo)
|
||||
public SubmitSoloScoreRequest(ScoreInfo scoreInfo, long scoreId, int beatmapId)
|
||||
: base(scoreInfo, scoreId)
|
||||
{
|
||||
this.beatmapId = beatmapId;
|
||||
this.scoreId = scoreId;
|
||||
Score = new SubmittableScore(scoreInfo);
|
||||
}
|
||||
|
||||
protected override WebRequest CreateWebRequest()
|
||||
{
|
||||
var req = base.CreateWebRequest();
|
||||
|
||||
req.ContentType = "application/json";
|
||||
req.Method = HttpMethod.Put;
|
||||
req.Timeout = 30000;
|
||||
|
||||
req.AddRaw(JsonConvert.SerializeObject(Score, new JsonSerializerSettings
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
|
||||
}));
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
protected override string Target => $@"beatmaps/{beatmapId}/solo/scores/{scoreId}";
|
||||
protected override string Target => $@"beatmaps/{beatmapId}/solo/scores/{ScoreId}";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user