summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-06-28 22:01:04 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-06-28 22:01:04 -0400
commit3f5a5e54041a641e30fc5cc899046953d9763da4 (patch)
treeca02735544614b85cfc75201823b3dd8d36f2b8a /src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs
parent89ad599561a058289d8ea44e0c345f1a30a3a6ac (diff)
downloadSMAPI-3f5a5e54041a641e30fc5cc899046953d9763da4.tar.gz
SMAPI-3f5a5e54041a641e30fc5cc899046953d9763da4.tar.bz2
SMAPI-3f5a5e54041a641e30fc5cc899046953d9763da4.zip
use more structured API response for update checks (#532)
Diffstat (limited to 'src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs')
-rw-r--r--src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs45
1 files changed, 39 insertions, 6 deletions
diff --git a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs
index e4ab168e..581a524c 100644
--- a/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs
+++ b/src/StardewModdingAPI.Toolkit/Framework/Clients/WebApi/ModEntryModel.cs
@@ -1,3 +1,5 @@
+using System;
+
namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
{
/// <summary>Metadata about a mod.</summary>
@@ -12,19 +14,50 @@ namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi
/// <summary>The mod name.</summary>
public string Name { get; set; }
+ /// <summary>The main version.</summary>
+ public ModEntryVersionModel Main { get; set; }
+
+ /// <summary>The latest optional version, if newer than <see cref="Main"/>.</summary>
+ public ModEntryVersionModel Optional { get; set; }
+
+ /// <summary>The errors that occurred while fetching update data.</summary>
+ public string[] Errors { get; set; } = new string[0];
+
+ /****
+ ** Backwards-compatible fields
+ ****/
/// <summary>The mod's latest version number.</summary>
- public string Version { get; set; }
+ [Obsolete("Use " + nameof(ModEntryModel.Main))]
+ internal string Version { get; private set; }
/// <summary>The mod's web URL.</summary>
- public string Url { get; set; }
+ [Obsolete("Use " + nameof(ModEntryModel.Main))]
+ internal string Url { get; private set; }
/// <summary>The mod's latest optional release, if newer than <see cref="Version"/>.</summary>
- public string PreviewVersion { get; set; }
+ [Obsolete("Use " + nameof(ModEntryModel.Optional))]
+ internal string PreviewVersion { get; private set; }
/// <summary>The web URL to the mod's latest optional release, if newer than <see cref="Version"/>.</summary>
- public string PreviewUrl { get; set; }
+ [Obsolete("Use " + nameof(ModEntryModel.Optional))]
+ internal string PreviewUrl { get; private set; }
- /// <summary>The errors that occurred while fetching update data.</summary>
- public string[] Errors { get; set; } = new string[0];
+
+ /*********
+ ** Public methods
+ *********/
+ /// <summary>Set backwards-compatible fields.</summary>
+ /// <param name="version">The requested API version.</param>
+ public void SetBackwardsCompatibility(ISemanticVersion version)
+ {
+ if (version.IsOlderThan("2.6-beta.19"))
+ {
+ this.Version = this.Main?.Version?.ToString();
+ this.Url = this.Main?.Url;
+
+ this.PreviewVersion = this.Optional?.Version?.ToString();
+ this.PreviewUrl = this.Optional?.Url;
+ }
+ }
}
}