summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
commita3f21685049cabf2d824c8060dc0b1de47e9449e (patch)
treead9add30e9da2a50e0ea0245f1546b7378f0d282 /src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs
parent6521df7b131924835eb797251c1e956fae0d6e13 (diff)
parent277bf082675b98b95bf6184fe3c7a45b969c7ac2 (diff)
downloadSMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.gz
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.bz2
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs')
-rw-r--r--src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs66
1 files changed, 53 insertions, 13 deletions
diff --git a/src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs b/src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs
index 18252298..46b98860 100644
--- a/src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs
+++ b/src/SMAPI.Web/Framework/ModRepositories/ModInfoModel.cs
@@ -9,15 +9,24 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories
/// <summary>The mod name.</summary>
public string Name { get; set; }
- /// <summary>The mod's latest release number.</summary>
+ /// <summary>The mod's latest version.</summary>
public string Version { get; set; }
- /// <summary>The mod's latest optional release, if newer than <see cref="Version"/>.</summary>
+ /// <summary>The mod's latest optional or prerelease version, if newer than <see cref="Version"/>.</summary>
public string PreviewVersion { get; set; }
/// <summary>The mod's web URL.</summary>
public string Url { get; set; }
+ /// <summary>The license URL, if available.</summary>
+ public string LicenseUrl { get; set; }
+
+ /// <summary>The license name, if available.</summary>
+ public string LicenseName { get; set; }
+
+ /// <summary>The mod availability status on the remote site.</summary>
+ public RemoteModStatus Status { get; set; } = RemoteModStatus.Ok;
+
/// <summary>The error message indicating why the mod is invalid (if applicable).</summary>
public string Error { get; set; }
@@ -26,31 +35,62 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories
** Public methods
*********/
/// <summary>Construct an empty instance.</summary>
- public ModInfoModel()
- {
- // needed for JSON deserialising
- }
+ public ModInfoModel() { }
/// <summary>Construct an instance.</summary>
/// <param name="name">The mod name.</param>
/// <param name="version">The semantic version for the mod's latest release.</param>
/// <param name="previewVersion">The semantic version for the mod's latest preview release, if available and different from <see cref="Version"/>.</param>
/// <param name="url">The mod's web URL.</param>
- /// <param name="error">The error message indicating why the mod is invalid (if applicable).</param>
- public ModInfoModel(string name, string version, string url, string previewVersion = null, string error = null)
+ public ModInfoModel(string name, string version, string url, string previewVersion = null)
+ {
+ this
+ .SetBasicInfo(name, url)
+ .SetVersions(version, previewVersion);
+ }
+
+ /// <summary>Set the basic mod info.</summary>
+ /// <param name="name">The mod name.</param>
+ /// <param name="url">The mod's web URL.</param>
+ public ModInfoModel SetBasicInfo(string name, string url)
{
this.Name = name;
+ this.Url = url;
+
+ return this;
+ }
+
+ /// <summary>Set the mod version info.</summary>
+ /// <param name="version">The semantic version for the mod's latest release.</param>
+ /// <param name="previewVersion">The semantic version for the mod's latest preview release, if available and different from <see cref="Version"/>.</param>
+ public ModInfoModel SetVersions(string version, string previewVersion = null)
+ {
this.Version = version;
this.PreviewVersion = previewVersion;
- this.Url = url;
- this.Error = error;
+
+ return this;
}
- /// <summary>Construct an instance.</summary>
- /// <param name="error">The error message indicating why the mod is invalid.</param>
- public ModInfoModel(string error)
+ /// <summary>Set the license info, if available.</summary>
+ /// <param name="url">The license URL.</param>
+ /// <param name="name">The license name.</param>
+ public ModInfoModel SetLicense(string url, string name)
{
+ this.LicenseUrl = url;
+ this.LicenseName = name;
+
+ return this;
+ }
+
+ /// <summary>Set a mod error.</summary>
+ /// <param name="status">The mod availability status on the remote site.</param>
+ /// <param name="error">The error message indicating why the mod is invalid (if applicable).</param>
+ public ModInfoModel SetError(RemoteModStatus status, string error)
+ {
+ this.Status = status;
this.Error = error;
+
+ return this;
}
}
}