Skip to content

Commit dc4da6d

Browse files
author
b1acksoil
committed
feat(data): support challenge api
1 parent 8171809 commit dc4da6d

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎ArcaeaUnlimitedAPI.Lib/ArcaeaUnlimitedAPI.Lib.csproj‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Title>ArcaeaUnlimitedAPI.Lib</Title>
5-
<PackageVersion>2.0.0</PackageVersion>
5+
<PackageVersion>2.1.0</PackageVersion>
66
<Authors>b1acksoil</Authors>
77
<Description>Lib for ArcaeaUnlimitedAPI.</Description>
88
<PackageTags>Arcaea</PackageTags>

‎ArcaeaUnlimitedAPI.Lib/Core/AuaDataApi.cs‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,4 +230,44 @@ public Task<int[][]> Density(string songname, ArcaeaDifficulty difficulty = Arca
230230
=> GetDensity(songname, AuaSongQueryType.SongName, difficulty);
231231

232232
#endregion /data/density
233+
234+
#region /data/challenge
235+
236+
private async Task<string> GetChallenge(string path, string? body, long? timestamp)
237+
{
238+
var qb = new QueryBuilder()
239+
.Add("path", path);
240+
241+
if (body is not null) qb.Add("body", body);
242+
if (timestamp is not null) qb.Add("timestamp", timestamp.ToString()!);
243+
244+
var response = JsonSerializer.Deserialize<AuaResponse<string>>(
245+
await _client.GetStringAsync("data/challenge" + qb.Build()))!;
246+
if (response.Status < 0)
247+
throw new AuaException(response.Status, response.Message!);
248+
return response.Content!;
249+
}
250+
251+
/// <summary>
252+
/// Get challenge of a specified arcapi path.
253+
/// </summary>
254+
/// <param name="path">Request arcapi path.</param>
255+
/// <param name="body">Request body, optional when body is empty.</param>
256+
/// <param name="timestamp">Request timestamp.</param>
257+
/// <returns>Challenge string.</returns>
258+
/// <remarks>It is designed for the release version of AUA, and not available for the release version.</remarks>
259+
public Task<string> Challenge(string path, string? body = null, long? timestamp = null)
260+
=> GetChallenge(path, body, timestamp);
261+
262+
/// <summary>
263+
/// Get challenge of a specified arcapi path.
264+
/// </summary>
265+
/// <param name="path">Request arcapi path.</param>
266+
/// <param name="timestamp">Request timestamp.</param>
267+
/// <returns>Challenge string.</returns>
268+
/// <remarks>It is designed for the release version of AUA, and not available for the release version.</remarks>
269+
public Task<string> Challenge(string path, long? timestamp = null)
270+
=> GetChallenge(path, null, timestamp);
271+
272+
#endregion /data/challenge
233273
}

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Console.WriteLine(songinfo.Difficulties[2].NameEn);
5858
- [x] [data/theory](https://github.com/Arcaea-Infinity/ArcaeaUnlimitedAPI-Wiki/blob/main/data/theory.md)
5959
- [x] [data/playdata](https://github.com/Arcaea-Infinity/ArcaeaUnlimitedAPI-Wiki/blob/main/data/playdata.md)
6060
- [x] [data/density](https://github.com/Arcaea-Infinity/ArcaeaUnlimitedAPI-Wiki/blob/main/data/density.md)
61-
- [ ] [data/challenge](https://github.com/Arcaea-Infinity/ArcaeaUnlimitedAPI-Wiki/blob/main/data/challenge.md)
61+
- [x] [data/challenge](https://github.com/Arcaea-Infinity/ArcaeaUnlimitedAPI-Wiki/blob/main/data/challenge.md)
6262

6363
## License
6464

0 commit comments

Comments
 (0)