summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 21:49:05 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2017-09-22 21:49:05 -0400
commitecdbefffd9c0acbbecd8178d7d2ac285715b5e7f (patch)
tree205c0638ef13ebf2109563f41f925306ed8dc9b6 /src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs
parentba5cc149e265d3f14246db23b09c8feb5f9c0d3a (diff)
downloadSMAPI-ecdbefffd9c0acbbecd8178d7d2ac285715b5e7f.tar.gz
SMAPI-ecdbefffd9c0acbbecd8178d7d2ac285715b5e7f.tar.bz2
SMAPI-ecdbefffd9c0acbbecd8178d7d2ac285715b5e7f.zip
move hardcoded values into config (#336)
Diffstat (limited to 'src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs')
-rw-r--r--src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs18
1 files changed, 13 insertions, 5 deletions
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