diff options
Diffstat (limited to 'src/StardewModdingAPI.Web/Framework')
-rw-r--r-- | src/StardewModdingAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs | 21 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs | 18 |
2 files changed, 34 insertions, 5 deletions
diff --git a/src/StardewModdingAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs b/src/StardewModdingAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs new file mode 100644 index 00000000..c8763800 --- /dev/null +++ b/src/StardewModdingAPI.Web/Framework/ConfigModels/ModUpdateCheckConfig.cs @@ -0,0 +1,21 @@ +namespace StardewModdingAPI.Web.Framework.ConfigModels +{ + /// <summary>The config settings for mod update checks.</summary> + public class ModUpdateCheckConfig + { + /// <summary>The number of minutes update checks should be cached before refetching them.</summary> + public int CacheMinutes { get; set; } + + /// <summary>The repository key for Nexus Mods.</summary> + public string NexusKey { get; set; } + + /// <summary>The user agent for the Nexus Mods API client.</summary> + public string NexusUserAgent { get; set; } + + /// <summary>The base URL for the Nexus Mods API.</summary> + public string NexusBaseUrl { get; set; } + + /// <summary>The URL for a Nexus Mods API query excluding the <see cref="NexusBaseUrl"/>, where {0} is the mod ID.</summary> + public string NexusModUrlFormat { get; set; } + } +} diff --git a/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs index 02c2939a..312058ae 100644 --- a/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs +++ b/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs @@ -20,17 +20,25 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories ** Accessors *********/ /// <summary>The unique key for this vendor.</summary> - public string VendorKey { get; } = "Nexus"; + public string VendorKey { get; } + + /// <summary>The URL for a Nexus Mods API query excluding the base URL, where {0} is the mod ID.</summary> + public string ModUrlFormat { get; } /********* ** Public methods *********/ /// <summary>Construct an instance.</summary> - public NexusRepository() + /// <param name="vendorKey">The unique key for this vendor.</param> + /// <param name="userAgent">The user agent for the Nexus Mods API client.</param> + /// <param name="baseUrl">The base URL for the Nexus Mods API.</param> + /// <param name="modUrlFormat">The URL for a Nexus Mods API query excluding the <paramref name="baseUrl"/>, where {0} is the mod ID.</param> + public NexusRepository(string vendorKey, string userAgent, string baseUrl, string modUrlFormat) { - this.Client = new FluentClient("http://www.nexusmods.com/stardewvalley") - .SetUserAgent("Nexus Client v0.63.15"); + this.VendorKey = vendorKey; + this.ModUrlFormat = modUrlFormat; + this.Client = new FluentClient(baseUrl).SetUserAgent(userAgent); } /// <summary>Get metadata about a mod in the repository.</summary> @@ -40,7 +48,7 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories try { NexusResponseModel response = await this.Client - .GetAsync($"mods/{id}") + .GetAsync(string.Format(this.ModUrlFormat, id)) .As<NexusResponseModel>(); return response != null |