diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-22 00:58:25 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-09-22 00:58:25 -0400 |
commit | 9c072333d161d2510ee884d71dc9a714bbf86033 (patch) | |
tree | 5c12a085b8d78ff4dcf27062658d2ea99ded9752 /src/StardewModdingAPI.Web | |
parent | 2c02dfe45a6d1252bfef557db8f39f97e57d3d19 (diff) | |
download | SMAPI-9c072333d161d2510ee884d71dc9a714bbf86033.tar.gz SMAPI-9c072333d161d2510ee884d71dc9a714bbf86033.tar.bz2 SMAPI-9c072333d161d2510ee884d71dc9a714bbf86033.zip |
rename mods endpoint & model (#336)
Diffstat (limited to 'src/StardewModdingAPI.Web')
-rw-r--r-- | src/StardewModdingAPI.Web/Controllers/ModsController.cs (renamed from src/StardewModdingAPI.Web/Controllers/CheckController.cs) | 12 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Framework/ModRepositories/IModRepository.cs | 2 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs | 6 | ||||
-rw-r--r-- | src/StardewModdingAPI.Web/Models/ModInfoModel.cs (renamed from src/StardewModdingAPI.Web/Models/ModGenericModel.cs) | 6 |
4 files changed, 13 insertions, 13 deletions
diff --git a/src/StardewModdingAPI.Web/Controllers/CheckController.cs b/src/StardewModdingAPI.Web/Controllers/ModsController.cs index 2a346cf3..bbf1744f 100644 --- a/src/StardewModdingAPI.Web/Controllers/CheckController.cs +++ b/src/StardewModdingAPI.Web/Controllers/ModsController.cs @@ -10,8 +10,7 @@ namespace StardewModdingAPI.Web.Controllers { /// <summary>Provides an API to perform mod update checks.</summary> [Produces("application/json")] - [Route("api/check")] - public class CheckController : Controller + public class ModsController : Controller { /********* ** Properties @@ -31,23 +30,24 @@ namespace StardewModdingAPI.Web.Controllers /// <summary>Fetch version metadata for the given mods.</summary> /// <param name="search">The mod update search criteria.</param> [HttpPost] - public async Task<ModGenericModel[]> Post([FromBody] ModSearchModel search) + [Route("mods")] + public async Task<ModInfoModel[]> Post([FromBody] ModSearchModel search) { - IList<ModGenericModel> result = new List<ModGenericModel>(); + IList<ModInfoModel> result = new List<ModInfoModel>(); foreach (string modKey in search.ModKeys) { // parse mod key if (!this.TryParseModKey(modKey, out string vendorKey, out string modID)) { - result.Add(new ModGenericModel(modKey, "The mod key isn't in a valid format. It should contain the mod repository key and mod ID like 'Nexus:541'.")); + result.Add(new ModInfoModel(modKey, "The mod key isn't in a valid format. It should contain the mod repository key and mod ID like 'Nexus:541'.")); continue; } // get matching repository if (!this.Repositories.TryGetValue(vendorKey, out IModRepository repository)) { - result.Add(new ModGenericModel(modKey, "There's no mod repository matching this namespaced mod ID.")); + result.Add(new ModInfoModel(modKey, "There's no mod repository matching this namespaced mod ID.")); continue; } diff --git a/src/StardewModdingAPI.Web/Framework/ModRepositories/IModRepository.cs b/src/StardewModdingAPI.Web/Framework/ModRepositories/IModRepository.cs index 43bad4e9..7fd735cd 100644 --- a/src/StardewModdingAPI.Web/Framework/ModRepositories/IModRepository.cs +++ b/src/StardewModdingAPI.Web/Framework/ModRepositories/IModRepository.cs @@ -19,6 +19,6 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories *********/ /// <summary>Get metadata about a mod in the repository.</summary> /// <param name="id">The mod ID in this repository.</param> - Task<ModGenericModel> GetModInfoAsync(string id); + Task<ModInfoModel> GetModInfoAsync(string id); } } diff --git a/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs index 37f309da..74eef2ef 100644 --- a/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs +++ b/src/StardewModdingAPI.Web/Framework/ModRepositories/NexusRepository.cs @@ -35,18 +35,18 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories /// <summary>Get metadata about a mod in the repository.</summary> /// <param name="id">The mod ID in this repository.</param> - public async Task<ModGenericModel> GetModInfoAsync(string id) + public async Task<ModInfoModel> GetModInfoAsync(string id) { try { NexusResponseModel response = await this.Client .GetAsync($"mods/{id}") .As<NexusResponseModel>(); - return new ModGenericModel($"{this.VendorKey}:{id}", response.Name, response.Version, response.Url); + return new ModInfoModel($"{this.VendorKey}:{id}", response.Name, response.Version, response.Url); } catch (Exception ex) { - return new ModGenericModel($"{this.VendorKey}:{id}", ex.ToString()); + return new ModInfoModel($"{this.VendorKey}:{id}", ex.ToString()); } } diff --git a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs b/src/StardewModdingAPI.Web/Models/ModInfoModel.cs index 88a6e4bd..723d6c73 100644 --- a/src/StardewModdingAPI.Web/Models/ModGenericModel.cs +++ b/src/StardewModdingAPI.Web/Models/ModInfoModel.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; namespace StardewModdingAPI.Web.Models { /// <summary>Generic metadata about a mod.</summary> - public class ModGenericModel + public class ModInfoModel { /********* ** Accessors @@ -34,7 +34,7 @@ namespace StardewModdingAPI.Web.Models /// <param name="url">The mod's web URL.</param> /// <param name="error">The error message indicating why the mod is invalid (if applicable).</param> [JsonConstructor] - public ModGenericModel(string modKey, string name, string version, string url, string error = null) + public ModInfoModel(string modKey, string name, string version, string url, string error = null) { this.ModKey = modKey; this.Name = name; @@ -46,7 +46,7 @@ namespace StardewModdingAPI.Web.Models /// <summary>Construct an valid instance.</summary> /// <param name="modKey">The namespaced mod key.</param> /// <param name="error">The error message indicating why the mod is invalid.</param> - public ModGenericModel(string modKey, string error) + public ModInfoModel(string modKey, string error) { this.ModKey = modKey; this.Error = error; |