using System.IO; using System.Text.Json; using System.Windows; namespace Bokhantarare; public class BareBookInfo(string editionId, string title, string? workId = null) { string WorkID { get; set; } = workId??""; string EditionID { get; set; } = editionId; string Title { get; set; } = title; public Book getBook() { Dictionary? responce = JsonSerializer.Deserialize>( Helper.Request($"https://openlibrary.org/books/{EditionID}.json") ?? throw new Exception("Network Error")); if (responce == null) { throw new Exception("Failed to get book info"); } object? isbn_13_raw_array = 0; if (responce.ContainsKey("isbn_13")) { isbn_13_raw_array = responce["isbn_13"]; } else if(responce.ContainsKey("isbn_10")) { isbn_13_raw_array = responce["isbn_10"]; } else { throw new Exception("Failed to get ISBN"); } if (isbn_13_raw_array == null) { throw new Exception("Failed to get book info"); } List isbn_13_array = JsonSerializer.Deserialize>(isbn_13_raw_array.ToString()); return Book.GetBookFromISBN(isbn_13_array[0])??throw new Exception("Failed to get book info"); } public override string ToString() { return Title; } }