From 0b8b67182c989c070e04d93eb69416425f33502f Mon Sep 17 00:00:00 2001 From: Binary Alley Date: Tue, 3 Sep 2024 19:54:41 +0300 Subject: [PATCH] Adds in the Web app the required deserialization DTOs for interaction with the books API endpoint --- .../Common/Contracts/Books/AddBookRequest.cs | 33 +++++++++ .../Common/Enums/AudioRatingSource.cs | 27 ++++++++ .../Common/Enums/BookFormat.cs | 67 +++++++++++++++++++ .../Common/Enums/BookRatingSource.cs | 27 ++++++++ .../Common/Enums/IsbnFormat.cs | 19 ++++++ .../Common/Enums/VideoRatingSource.cs | 32 +++++++++ .../Common/Models/Books/BookRatingDto.cs | 19 ++++++ .../Common/Models/Books/BookSeriesDto.cs | 14 ++++ .../Common/Models/Books/IsbnDto.cs | 23 +++++++ .../Models/Books/WrittenContentMetadataDto.cs | 63 +++++++++++++++++ .../Common/Models/Common/GenreDto.cs | 14 ++++ .../Common/Models/Common/LanguageInfoDto.cs | 24 +++++++ .../Common/Models/Common/RatingDto.cs | 24 +++++++ .../Common/Models/Common/ReleaseInfoDto.cs | 40 +++++++++++ .../Common/Models/Common/TagDto.cs | 14 ++++ .../Contributors/MediaContributorDto.cs | 19 ++++++ .../Contributors/MediaContributorNameDto.cs | 19 ++++++ .../Contributors/MediaContributorRoleDto.cs | 19 ++++++ src/Lumina.Presentation.Web/Program.cs | 30 +++++++-- 19 files changed, 521 insertions(+), 6 deletions(-) create mode 100644 src/Lumina.Presentation.Web/Common/Contracts/Books/AddBookRequest.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/AudioRatingSource.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/BookFormat.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/BookRatingSource.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/IsbnFormat.cs create mode 100644 src/Lumina.Presentation.Web/Common/Enums/VideoRatingSource.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Books/BookRatingDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Books/BookSeriesDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Books/IsbnDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Books/WrittenContentMetadataDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Common/GenreDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Common/LanguageInfoDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Common/RatingDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Common/ReleaseInfoDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Common/TagDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorNameDto.cs create mode 100644 src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorRoleDto.cs diff --git a/src/Lumina.Presentation.Web/Common/Contracts/Books/AddBookRequest.cs b/src/Lumina.Presentation.Web/Common/Contracts/Books/AddBookRequest.cs new file mode 100644 index 00000000..c86890a5 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Contracts/Books/AddBookRequest.cs @@ -0,0 +1,33 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Models.Books; +using Lumina.Presentation.Web.Common.Models.Contributors; +using Lumina.Presentation.Web.Common.Enums; +#endregion + +namespace Lumina.Presentation.Web.Common.Contracts.Books; + +/// +/// Represents a request to add a book. +/// +public class AddBookRequest +{ + #region ==================================================================== PROPERTIES ================================================================================= + public WrittenContentMetadataDto? Metadata { get; set; } + public BookFormat? Format { get; set; } + public string? Edition { get; set; } + public int? VolumeNumber { get; set; } + public BookSeriesDto? Series { get; set; } + public string? ASIN { get; set; } + public string? GoodreadsId { get; set; } + public string? LCCN { get; set; } + public string? OCLCNumber { get; set; } + public string? OpenLibraryId { get; set; } + public string? LibraryThingId { get; set; } + public string? GoogleBooksId { get; set; } + public string? BarnesAndNobleId { get; set; } + public string? AppleBooksId { get; set; } + public List? ISBNs { get; set; } + public List? Contributors { get; set; } + public List? Ratings { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/AudioRatingSource.cs b/src/Lumina.Presentation.Web/Common/Enums/AudioRatingSource.cs new file mode 100644 index 00000000..96ac24bf --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/AudioRatingSource.cs @@ -0,0 +1,27 @@ +namespace Lumina.Presentation.Web.Common.Enums; + +/// +/// Enumeration for the various sources of audio ratings. +/// +public enum AudioRatingSource +{ + /// + /// Ratings provided by users of the Lumina media library. + /// + User, + + /// + /// Ratings sourced from MusicBrainz, an open music encyclopedia that collects music metadata. + /// + MusicBrainz, + + /// + /// Ratings obtained from Discogs, a database and marketplace for music recordings. + /// + Discogs, + + /// + /// Ratings from Last.fm, a music website that provides music recommendations based on user listening habits. + /// + LastFm, +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/BookFormat.cs b/src/Lumina.Presentation.Web/Common/Enums/BookFormat.cs new file mode 100644 index 00000000..90badca1 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/BookFormat.cs @@ -0,0 +1,67 @@ +namespace Lumina.Presentation.Web.Common.Enums; + +/// +/// Enumeration for various book formats. +/// +public enum BookFormat +{ + /// + /// A book bound with rigid protective covers (typically cardboard covered with cloth, heavy paper, or leather). + /// + Hardcover, + + /// + /// A book with a flexible paper cover, typically less durable than a hardcover. + /// + Paperback, + + /// + /// A small, usually non-illustrated, and inexpensive paperback book. + /// + MassMarketPaperback, + + /// + /// A larger, often higher-quality paperback book, typically used for literary fiction and nonfiction. + /// + TradePaperback, + + /// + /// A digital version of a book that can be read on electronic devices. + /// + eBook, + + /// + /// A recorded audio version of a book, either on physical media or as a digital file. + /// + Audiobook, + + /// + /// A book printed with larger text for easier reading, often used by those with visual impairments. + /// + LargePrint, + + /// + /// A sturdy book with thick cardboard pages, typically designed for young children. + /// + BoardBook, + + /// + /// A book bound with a spiral wire or plastic coil, allowing it to lay flat when open. + /// + SpiralBound, + + /// + /// A reinforced binding designed for frequent use, often used in schools and public libraries. + /// + LibraryBinding, + + /// + /// A book bound in leather, often used for luxury or collector's editions. + /// + LeatherBound, + + /// + /// A book with three-dimensional paper engineering, creating pop-up or movable parts. + /// + PopupBook +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/BookRatingSource.cs b/src/Lumina.Presentation.Web/Common/Enums/BookRatingSource.cs new file mode 100644 index 00000000..a00aca2b --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/BookRatingSource.cs @@ -0,0 +1,27 @@ +namespace Lumina.Presentation.Web.Common.Enums; + +/// +/// Enumeration for the various sources of book ratings. +/// +public enum BookRatingSource +{ + /// + /// Ratings provided by users of the Lumina system. + /// + User, + + /// + /// Ratings sourced from Goodreads, a social network for book readers that provides book recommendations and reviews. + /// + Goodreads, + + /// + /// Ratings obtained from Amazon, an e-commerce platform that includes customer reviews and ratings for books. + /// + Amazon, + + /// + /// Ratings from Google Books, a service that searches the full text of books and magazines that Google has scanned and converted to text. + /// + GoogleBooks, +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/IsbnFormat.cs b/src/Lumina.Presentation.Web/Common/Enums/IsbnFormat.cs new file mode 100644 index 00000000..312f9d5c --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/IsbnFormat.cs @@ -0,0 +1,19 @@ +namespace Lumina.Presentation.Web.Common.Enums; + +/// +/// Enumeration for the different ISBN (International Standard Book Number) formats. +/// +public enum IsbnFormat +{ + /// + /// The 10-digit ISBN format used for books published before 2007. + /// Example: 0-306-40615-2 + /// + Isbn10, + + /// + /// The 13-digit ISBN format introduced in 2007, now the standard for all new books. + /// Example: 978-0-306-40615-7 + /// + Isbn13 +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Enums/VideoRatingSource.cs b/src/Lumina.Presentation.Web/Common/Enums/VideoRatingSource.cs new file mode 100644 index 00000000..a80b3859 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Enums/VideoRatingSource.cs @@ -0,0 +1,32 @@ +namespace Lumina.Presentation.Web.Common.Enums; + +/// +/// Enumeration for the various sources of video ratings. +/// +public enum VideoRatingSource +{ + /// + /// Ratings provided by users of the Lumina media library. + /// + User, + + /// + /// Ratings sourced from IMDb (Internet Movie Database), an online database of information related to films, TV programs, and video games. + /// + Imdb, + + /// + /// Ratings obtained from TheTVDB, an open database for television shows, including episode information and user ratings. + /// + TheTvDb, + + /// + /// Ratings from The Movie Database (TMDb), a community-built movie and TV database. + /// + TheMovieDb, + + /// + /// Ratings from Rotten Tomatoes, a review-aggregation website for film and television. + /// + RottenTomatoes, +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Books/BookRatingDto.cs b/src/Lumina.Presentation.Web/Common/Models/Books/BookRatingDto.cs new file mode 100644 index 00000000..2f5a3e44 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Books/BookRatingDto.cs @@ -0,0 +1,19 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Models.Common; +using Lumina.Presentation.Web.Common.Enums; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Books; + +/// +/// Represents a book rating. +/// +public class BookRatingDto : RatingDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the optional source of the rating (e.g., "Goodreads", "Amazon"). + /// + public BookRatingSource? Source { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Books/BookSeriesDto.cs b/src/Lumina.Presentation.Web/Common/Models/Books/BookSeriesDto.cs new file mode 100644 index 00000000..c3b00466 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Books/BookSeriesDto.cs @@ -0,0 +1,14 @@ +namespace Lumina.Presentation.Web.Common.Models.Books; + +/// +/// Represents a request to get book series information. +/// +public class BookSeriesDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the title of the book series. + /// + public string? Title { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Books/IsbnDto.cs b/src/Lumina.Presentation.Web/Common/Models/Books/IsbnDto.cs new file mode 100644 index 00000000..2b895ffe --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Books/IsbnDto.cs @@ -0,0 +1,23 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Enums; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Books; + +/// +/// Represents a request to get ISBN information. +/// +public class IsbnDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the value of the ISBN. + /// + public string? Value { get; set; } + + /// + /// Gets the format of the ISBN. + /// + public IsbnFormat? Format { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Books/WrittenContentMetadataDto.cs b/src/Lumina.Presentation.Web/Common/Models/Books/WrittenContentMetadataDto.cs new file mode 100644 index 00000000..a8a9602b --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Books/WrittenContentMetadataDto.cs @@ -0,0 +1,63 @@ +#region ========================================================================= USING ===================================================================================== +using Lumina.Presentation.Web.Common.Models.Common; +#endregion + +namespace Lumina.Presentation.Web.Common.Models.Books; + +/// +/// Represents written content metadata. +/// +public class WrittenContentMetadataDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the title of the media item. + /// + public string? Title { get; set; } + + /// + /// Gets the original title of the media item. + /// + public string? OriginalTitle { get; set; } + + /// + /// Gets the optional description of the media item. + /// + public string? Description { get; set; } + + /// + /// Gets the release information of the media item. + /// + public ReleaseInfoDto? ReleaseInfo { get; set; } + + /// + /// Gets the list of genres associated with the media item. + /// + public List? Genres { get; set; } + + /// + /// Gets the list of tags associated with the media item. + /// + public List? Tags { get; set; } + + /// + /// Gets the optional language of the media item. + /// + public LanguageInfoDto? Language { get; set; } + + /// + /// Gets the optional original language of the media item. + /// + public LanguageInfoDto? OriginalLanguage { get; set; } + + /// + /// Gets the publisher of the written content. + /// + public string? Publisher { get; set; } + + /// + /// Gets the number of pages in the written content. + /// + public int? PageCount { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Common/GenreDto.cs b/src/Lumina.Presentation.Web/Common/Models/Common/GenreDto.cs new file mode 100644 index 00000000..5f52f3f7 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Common/GenreDto.cs @@ -0,0 +1,14 @@ +namespace Lumina.Presentation.Web.Common.Models.Common; + +/// +/// Represents a request to get genre information. +/// +public class GenreDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name of the genre element of the media item. + /// + public string? Name { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Common/LanguageInfoDto.cs b/src/Lumina.Presentation.Web/Common/Models/Common/LanguageInfoDto.cs new file mode 100644 index 00000000..edd58d9f --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Common/LanguageInfoDto.cs @@ -0,0 +1,24 @@ +namespace Lumina.Presentation.Web.Common.Models.Common; + +/// +/// Represents a request to get language information. +/// +public class LanguageInfoDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the ISO 639-1 two-letter language code. + /// + public string? LanguageCode { get; set; } + + /// + /// Gets the full name of the language in English. + /// + public string? LanguageName { get; set; } + + /// + /// Gets an optional native name of the language. + /// + public string? NativeName { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Common/RatingDto.cs b/src/Lumina.Presentation.Web/Common/Models/Common/RatingDto.cs new file mode 100644 index 00000000..7393b25d --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Common/RatingDto.cs @@ -0,0 +1,24 @@ +namespace Lumina.Presentation.Web.Common.Models.Common; + +/// +/// Represents a rating. +/// +public abstract class RatingDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the numeric value of the rating. + /// + public decimal? Value { get; set; } + + /// + /// Gets the maximum possible rating value. + /// + public decimal? MaxValue { get; set; } + + /// + /// Gets the optional number of votes or reviews this rating is based on. + /// + public int? VoteCount { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Common/ReleaseInfoDto.cs b/src/Lumina.Presentation.Web/Common/Models/Common/ReleaseInfoDto.cs new file mode 100644 index 00000000..50e3210f --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Common/ReleaseInfoDto.cs @@ -0,0 +1,40 @@ +namespace Lumina.Presentation.Web.Common.Models.Common; + +/// +/// Represents a request to get release information. +/// +public class ReleaseInfoDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the optional original release date of the media item. + /// + public DateOnly? OriginalReleaseDate { get; set; } + + /// + /// Gets the optional original release year of the media item. + /// This is useful when only the year of original release is known. + /// + public int? OriginalReleaseYear { get; set; } + + /// + /// Gets the optional re-release or reissue date of the media item. + /// + public DateOnly? ReReleaseDate { get; set; } + + /// + /// Gets the optional re-release or reissue year of the media item. + /// + public int? ReReleaseYear { get; set; } + + /// + /// Gets the optional country or region of release. + /// + public string? ReleaseCountry { get; set; } + + /// + /// Gets the optional release version or edition. (e.g. "Original", "Director's Cut", "2.0") + /// + public string? ReleaseVersion { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Common/TagDto.cs b/src/Lumina.Presentation.Web/Common/Models/Common/TagDto.cs new file mode 100644 index 00000000..b0158858 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Common/TagDto.cs @@ -0,0 +1,14 @@ +namespace Lumina.Presentation.Web.Common.Models.Common; + +/// +/// Represents a request to get tag information. +/// +public class TagDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name of the tag element of the media item. + /// + public string? Name { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorDto.cs b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorDto.cs new file mode 100644 index 00000000..4fb49846 --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorDto.cs @@ -0,0 +1,19 @@ +namespace Lumina.Presentation.Web.Common.Models.Contributors; + +/// +/// Represents a media contributor. +/// +public class MediaContributorDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name of the contributor. + /// + public MediaContributorNameDto? Name { get; set; } + + /// + /// Gets the role of the contributor. + /// + public MediaContributorRoleDto? Role { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorNameDto.cs b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorNameDto.cs new file mode 100644 index 00000000..f54968ae --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorNameDto.cs @@ -0,0 +1,19 @@ +namespace Lumina.Presentation.Web.Common.Models.Contributors; + +/// +/// Represents a media contributor name. +/// +public class MediaContributorNameDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the name by which the contributor is popularly known. + /// + public string? DisplayName { get; set; } + + /// + /// Gets the legal name of the contributor. + /// + public string? LegalName { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorRoleDto.cs b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorRoleDto.cs new file mode 100644 index 00000000..9a46ceff --- /dev/null +++ b/src/Lumina.Presentation.Web/Common/Models/Contributors/MediaContributorRoleDto.cs @@ -0,0 +1,19 @@ +namespace Lumina.Presentation.Web.Common.Models.Contributors; + +/// +/// Represents a media contributor role. +/// +public class MediaContributorRoleDto +{ + #region ==================================================================== PROPERTIES ================================================================================= + /// + /// Gets the value representing this object. + /// + public string? Name { get; set; } + + /// + /// Gets the category of this object. + /// + public string? Category { get; set; } + #endregion +} \ No newline at end of file diff --git a/src/Lumina.Presentation.Web/Program.cs b/src/Lumina.Presentation.Web/Program.cs index 5c18969a..5a62c609 100644 --- a/src/Lumina.Presentation.Web/Program.cs +++ b/src/Lumina.Presentation.Web/Program.cs @@ -1,11 +1,29 @@ +#region ========================================================================= USING ===================================================================================== using Microsoft.AspNetCore.Components.Web; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; -using Lumina.Presentation.Web; +#endregion -var builder = WebAssemblyHostBuilder.CreateDefault(args); -builder.RootComponents.Add("#app"); -builder.RootComponents.Add("head::after"); +namespace Lumina.Presentation.Web; -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); +/// +/// Application entry point, contains the composition root module, wires up all dependencies of the application. +/// +public class Program +{ + #region ===================================================================== METHODS =================================================================================== + /// + /// Application entry point. + /// + /// Optional command line arguments. + public static async Task Main(string[] args) + { + var builder = WebAssemblyHostBuilder.CreateDefault(args); + builder.RootComponents.Add("#app"); + builder.RootComponents.Add("head::after"); -await builder.Build().RunAsync(); + builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); + + await builder.Build().RunAsync(); + } + #endregion +} \ No newline at end of file