diff --git a/SabreTools.RedumpLib.Test/Endpoints/AboutTests.cs b/SabreTools.RedumpLib.Test/Endpoints/AboutTests.cs
new file mode 100644
index 0000000..3a1c466
--- /dev/null
+++ b/SabreTools.RedumpLib.Test/Endpoints/AboutTests.cs
@@ -0,0 +1,20 @@
+using Xunit;
+
+namespace SabreTools.RedumpLib.Test.Endpoints
+{
+ public class AboutTests
+ {
+ #region BuildUrl
+
+ [Fact]
+ public void BuildAboutUrl_Constant()
+ {
+ var endpoint = new RedumpLib.Endpoints.About();
+
+ string actual = endpoint.BuildUrl();
+ Assert.Equal("https://redump.info/about", actual);
+ }
+
+ #endregion
+ }
+}
diff --git a/SabreTools.RedumpLib.Test/Endpoints/DiscTests.cs b/SabreTools.RedumpLib.Test/Endpoints/DiscTests.cs
new file mode 100644
index 0000000..e7a4aae
--- /dev/null
+++ b/SabreTools.RedumpLib.Test/Endpoints/DiscTests.cs
@@ -0,0 +1,38 @@
+using SabreTools.RedumpLib.Data;
+using Xunit;
+
+namespace SabreTools.RedumpLib.Test.Endpoints
+{
+ public class DiscTests
+ {
+ #region BuildUrl
+
+ [Theory]
+ [InlineData(1, 1)]
+ [InlineData(-1, 1)]
+ public void BuildDiscUrl_AlwaysPositive(int id, int expected)
+ {
+ var endpoint = new RedumpLib.Endpoints.Disc { Id = id };
+ string actual = endpoint.BuildUrl();
+ Assert.Equal($"https://redump.info/disc/{expected}", actual);
+ }
+
+ [Theory]
+ [InlineData(null, "https://redump.info/disc/1")]
+ [InlineData(DiscSubpath.Cuesheet, "https://redump.info/disc/1/cue")]
+ [InlineData(DiscSubpath.Edit, "https://redump.info/disc/1/edit")]
+ [InlineData(DiscSubpath.SBI, "https://redump.info/disc/1/sbi")]
+ public void BuildDiscUrl_Subpath_Builds(DiscSubpath? subpath, string expected)
+ {
+ var endpoint = new RedumpLib.Endpoints.Disc
+ {
+ Id = 1,
+ Subpath = subpath,
+ };
+ string actual = endpoint.BuildUrl();
+ Assert.Equal(expected, actual);
+ }
+
+ #endregion
+ }
+}
diff --git a/SabreTools.RedumpLib.Test/Web/UrlBuilderTests.cs b/SabreTools.RedumpLib.Test/Web/UrlBuilderTests.cs
index cbc9ec8..3935b5b 100644
--- a/SabreTools.RedumpLib.Test/Web/UrlBuilderTests.cs
+++ b/SabreTools.RedumpLib.Test/Web/UrlBuilderTests.cs
@@ -7,41 +7,6 @@ namespace SabreTools.RedumpLib.Test.Web
{
public class UrlBuilderTests
{
- #region BuildAboutUrl
-
- [Fact]
- public void BuildAboutUrl_Constant()
- {
- string actual = UrlBuilder.BuildAboutUrl();
- Assert.Equal("https://redump.info/about", actual);
- }
-
- #endregion
-
- #region BuildDiscUrl
-
- [Theory]
- [InlineData(1, 1)]
- [InlineData(-1, 1)]
- public void BuildDiscUrl_AlwaysPositive(int id, int expected)
- {
- string actual = UrlBuilder.BuildDiscUrl(id);
- Assert.Equal($"https://redump.info/disc/{expected}", actual);
- }
-
- [Theory]
- [InlineData(null, "https://redump.info/disc/1")]
- [InlineData(DiscSubpath.Cuesheet, "https://redump.info/disc/1/cue")]
- [InlineData(DiscSubpath.Edit, "https://redump.info/disc/1/edit")]
- [InlineData(DiscSubpath.SBI, "https://redump.info/disc/1/sbi")]
- public void BuildDiscUrl_Subpath_Builds(DiscSubpath? subpath, string expected)
- {
- string actual = UrlBuilder.BuildDiscUrl(1, subpath);
- Assert.Equal(expected, actual);
- }
-
- #endregion
-
#region BuildDownloadsUrl
[Theory]
diff --git a/SabreTools.RedumpLib/Endpoints/About.cs b/SabreTools.RedumpLib/Endpoints/About.cs
new file mode 100644
index 0000000..3f1ee3d
--- /dev/null
+++ b/SabreTools.RedumpLib/Endpoints/About.cs
@@ -0,0 +1,24 @@
+using System;
+using Newtonsoft.Json;
+
+namespace SabreTools.RedumpLib.Endpoints
+{
+ [JsonObject("about")]
+ public class About
+ {
+ ///
+ /// Build a /discs/ path URL
+ ///
+ public string BuildUrl()
+ {
+ var ub = new UriBuilder
+ {
+ Scheme = "https",
+ Host = "redump.info",
+ Path = "about",
+ };
+
+ return ub.ToString();
+ }
+ }
+}
diff --git a/SabreTools.RedumpLib/Endpoints/Disc.cs b/SabreTools.RedumpLib/Endpoints/Disc.cs
new file mode 100644
index 0000000..bdcab56
--- /dev/null
+++ b/SabreTools.RedumpLib/Endpoints/Disc.cs
@@ -0,0 +1,47 @@
+using System;
+using Newtonsoft.Json;
+using SabreTools.RedumpLib.Data;
+
+namespace SabreTools.RedumpLib.Endpoints
+{
+ /// TODO: Handle submit path?
+ [JsonObject("disc")]
+ public class Disc
+ {
+ [JsonProperty("id")]
+ public int Id { get; set; }
+
+ [JsonProperty("subpath")]
+ public DiscSubpath? Subpath { get; set; }
+
+ ///
+ /// Build a /discs/ path URL
+ ///
+ public string BuildUrl()
+ {
+ var ub = new UriBuilder
+ {
+ Scheme = "https",
+ Host = "redump.info",
+ Path = $"disc/{Math.Abs(Id)}",
+ };
+
+ switch (Subpath)
+ {
+ case DiscSubpath.Cuesheet:
+ case DiscSubpath.Edit:
+ case DiscSubpath.SBI:
+ ub.Path += $"/{Subpath.ShortName()}";
+ break;
+
+ // History and null are invalid for a disc page
+ case DiscSubpath.History:
+ case null:
+ default:
+ break;
+ }
+
+ return ub.ToString();
+ }
+ }
+}
diff --git a/SabreTools.RedumpLib/Web/Client.cs b/SabreTools.RedumpLib/Web/Client.cs
index c7aa65d..6ced575 100644
--- a/SabreTools.RedumpLib/Web/Client.cs
+++ b/SabreTools.RedumpLib/Web/Client.cs
@@ -1149,7 +1149,8 @@ namespace SabreTools.RedumpLib.Web
try
{
// Try to retrieve the data
- string discPageUri = UrlBuilder.BuildDiscUrl(id);
+ var endpoint = new Endpoints.Disc { Id = id };
+ string discPageUri = endpoint.BuildUrl();
string? discPage = await DownloadString(discPageUri);
if (discPage is null)
@@ -1197,7 +1198,8 @@ namespace SabreTools.RedumpLib.Web
try
{
// Try to retrieve the data
- string discPageUri = UrlBuilder.BuildDiscUrl(id);
+ var endpoint = new Endpoints.Disc { Id = id };
+ string discPageUri = endpoint.BuildUrl();
string? discPage = await DownloadString(discPageUri);
if (discPage is null)
@@ -1265,7 +1267,12 @@ namespace SabreTools.RedumpLib.Web
// View Edit History
if ((discSubpaths is null || Array.Exists(discSubpaths, s => s is DiscSubpath.History)) && discPage.Contains($" s is DiscSubpath.Edit)) && discPage.Contains($" s is DiscSubpath.Cuesheet)) && discPage.Contains($" s is DiscSubpath.SBI)) && discPage.Contains($"
- /// Build a /about/ path URL
- ///
- public static string BuildAboutUrl()
- {
- var ub = new UriBuilder
- {
- Scheme = "https",
- Host = "redump.info",
- Path = "about",
- };
-
- return ub.ToString();
- }
-
- ///
- /// Build a /disc/ path URL
- ///
- /// Disc ID, required
- /// Disc page subpath, null to omit
- /// TODO: Handle submit path?
- public static string BuildDiscUrl(int id, DiscSubpath? subpath = null)
- {
- var ub = new UriBuilder
- {
- Scheme = "https",
- Host = "redump.info",
- Path = $"disc/{Math.Abs(id)}",
- };
-
- switch (subpath)
- {
- case DiscSubpath.Cuesheet:
- case DiscSubpath.Edit:
- case DiscSubpath.SBI:
- ub.Path += $"/{subpath.ShortName()}";
- break;
-
- // History and null are invalid for a disc page
- case DiscSubpath.History:
- case null:
- default:
- break;
- }
-
- return ub.ToString();
- }
-
///
/// Build a /downloads/ path URL
///