using System; namespace StardewModdingAPI.Toolkit.Framework.Clients.WebApi { /// Metadata about a mod. public class ModEntryModel { /********* ** Accessors *********/ /// The mod's unique ID (if known). public string ID { get; set; } /// The main version. public ModEntryVersionModel Main { get; set; } /// The latest optional version, if newer than . public ModEntryVersionModel Optional { get; set; } /// The latest unofficial version, if newer than and . public ModEntryVersionModel Unofficial { get; set; } /// Optional extended data which isn't needed for update checks. public ModExtendedMetadataModel Metadata { get; set; } /// The errors that occurred while fetching update data. public string[] Errors { get; set; } = new string[0]; /**** ** Backwards-compatible fields ****/ /// The mod's latest version number. [Obsolete("Use " + nameof(ModEntryModel.Main))] internal string Version { get; private set; } /// The mod's web URL. [Obsolete("Use " + nameof(ModEntryModel.Main))] internal string Url { get; private set; } /// The mod's latest optional release, if newer than . [Obsolete("Use " + nameof(ModEntryModel.Optional))] internal string PreviewVersion { get; private set; } /// The web URL to the mod's latest optional release, if newer than . [Obsolete("Use " + nameof(ModEntryModel.Optional))] internal string PreviewUrl { get; private set; } /********* ** Public methods *********/ /// Set backwards-compatible fields. /// The requested API version. 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; } } } }