using ModVersionChecker.enums; using ModVersionChecker.utils; using System.Text.Json.Serialization; namespace ModVersionChecker.repository.api.dto { public class AppResponse { public AppResponse() { } [JsonPropertyName("id")] public string Id { get; set; } = string.Empty; [JsonPropertyName("uid")] public string Uid { get; set; } = string.Empty; [JsonPropertyName("name")] public string Name { get; set; } = string.Empty; [JsonPropertyName("type")] public string Type { get; set; } = string.Empty; [JsonPropertyName("source")] public string Source { get; set; } = string.Empty; [JsonPropertyName("params")] public Dictionary Params { get; set; } = new Dictionary(); [JsonPropertyName("fields")] public Dictionary Fields { get; set; } = new Dictionary(); [JsonPropertyName("downloadUrl")] public string DownloadUrl { get; set; } = string.Empty; [JsonPropertyName("currentVersion")] public string CurrentVersion { get; set; } = string.Empty; [JsonPropertyName("latestVersion")] public string LatestVersion { get; set; } = string.Empty; [JsonPropertyName("status")] [JsonConverter(typeof(JsonStringEnumConverter))] public AppStatus Status { get; set; } = AppStatus.NONE; [JsonPropertyName("createdAt")] public long CreatedAt { get; set; } = 0; [JsonPropertyName("updatedAt")] public long UpdatedAt { get; set; } = 0; [JsonPropertyName("lastCheckedAt")] public long LastCheckedAt { get; set; } = 0; [JsonPropertyName("active")] public bool Active { get; set; } = false; public static App toModel(AppResponse appResponse) { if (appResponse == null) { return new App(); } return new App() { Id = appResponse.Id, Uid = appResponse.Uid, Name = appResponse.Name, Type = appResponse.Type, Source = appResponse.Source, Params = appResponse.Params, Fields = appResponse.Fields, DownloadUrl = appResponse.DownloadUrl, CurrentVersion = appResponse.CurrentVersion, LatestVersion = appResponse.LatestVersion, Status = appResponse.Status, LastCheckedAt = appResponse.LastCheckedAt, LocalCheckedAt = TimeUtils.GetUnixTimeMillis(null) }; } } }