diff --git a/docs/technical/api/Api.Book.md b/docs/technical/api/Api.Book.md index 71947702..bfd50be8 100644 --- a/docs/technical/api/Api.Book.md +++ b/docs/technical/api/Api.Book.md @@ -16,25 +16,101 @@ #### Add Book Request ```js -POST /books +POST api/v1/books ``` ```json { - "name": "Yummy Menu", - "description": "A menu with yummy food", - "sections": [ - { - "name": "Appetizers", - "description": "Starters", - "items": [ - { - "name": "Fried Pickles", - "description": "Deep fried pickles" - } - ] - } - ] + "metadata": { + "title": "The Fellowship of the Ring", + "originalTitle": "The Fellowship of the Ring", + "description": "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.", + "releaseInfo": { + "originalReleaseDate": "1954-07-29", + "originalReleaseYear": 1954, + "reReleaseDate": "2001-09-06", + "reReleaseYear": 2001, + "releaseCountry": "uk", + "releaseVersion": "50th Anniversary Edition" + }, + "genres": [ + { "name": "fantasy" }, + { "name": "adventure" }, + { "name": "classic" } + ], + "tags": [ + { "name": "epic fantasy" }, + { "name": "quest" }, + { "name": "middle-earth" } + ], + "language": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "originalLanguage": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "publisher": "Houghton Mifflin", + "pageCount": 398 + }, + "format": "Paperback", + "edition": "50th Anniversary Edition", + "volumeNumber": 1, + "series": { + "title": "The Lord of the Rings" + }, + "asin": "B007978NPG", + "goodreadsId": "3", + "lccn": "54009621", + "oclcNumber": "ocm00012345", + "openLibraryId": "OL7603910M", + "libraryThingId": "3203347", + "googleBooksId": "aWZzLPhY4o0C", + "barnesAndNobleId": "1100307790", + "appleBooksId": "id395211", + "isbns": [ + { + "value": "0395272238", + "format": "Isbn10" + }, + { + "value": "9780395272237", + "format": "Isbn13" + } + ], + "contributors": [ + { + "name": "J.R.R. Tolkien", + "role": { + "name": "author", + "category": "book" + } + }, + { + "name": "Alan Lee", + "role": { + "name": "illustrator", + "category": "book" + } + } + ], + "ratings": [ + { + "source": "Goodreads", + "value": 4.36, + "maxValue": 5, + "voteCount": 2345678 + }, + { + "source": "Amazon", + "value": 4.7, + "maxValue": 5, + "voteCount": 87654 + } + ] } ``` @@ -46,33 +122,92 @@ POST /books ```json { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Yummy Menu", - "description": "A menu with yummy food", - "averageRating": null, - "sections": [ - { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Appetizers", - "description": "Starters", - "items": [ - { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Fried Pickles", - "description": "Deep fried pickles" - } - ] - } + "metadata": { + "publisher": "Houghton Mifflin", + "pageCount": 398, + "title": "The Fellowship of the Ring", + "originalTitle": "The Fellowship of the Ring", + "description": "The first part of J.R.R. Tolkien's epic adventure The Lord of the Rings. In a sleepy village in the Shire, young Frodo Baggins finds himself faced with an immense task, as his elderly cousin Bilbo entrusts the Ring to his care. Frodo must leave his home and make a perilous journey across Middle-earth to the Cracks of Doom, there to destroy the Ring and foil the Dark Lord in his evil purpose.", + "releaseInfo": { + "originalReleaseDate": "1954-07-29", + "originalReleaseYear": 1954, + "reReleaseDate": "2001-09-06", + "reReleaseYear": 2001, + "releaseCountry": "uk", + "releaseVersion": "50th Anniversary Edition" + }, + "language": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "originalLanguage": { + "languageCode": "en", + "languageName": "English", + "nativeName": "English" + }, + "tags": [ + { + "name": "epic fantasy" + }, + { + "name": "quest" + }, + { + "name": "middle-earth" + } ], - "hostId": "00000000-0000-0000-0000-000000000000", - "dinnerIds": [ - "00000000-0000-0000-0000-000000000000", - ], - "menuReviewIds": [ - "00000000-0000-0000-0000-000000000000", - ], - "createdDateTime": "2020-01-01T00:00:00.0000000Z", - "updatedDateTime": "2020-01-01T00:00:00.0000000Z" + "genres": [ + { + "name": "fantasy" + }, + { + "name": "adventure" + }, + { + "name": "classic" + } + ] + }, + "format": "Paperback", + "edition": "50th Anniversary Edition", + "volumeNumber": 1, + "series": null, + "asin": "B007978NPG", + "goodreadsId": "3", + "lccn": "54009621", + "oclcNumber": "ocm00012345", + "openLibraryId": "OL7603910M", + "libraryThingId": "3203347", + "googleBooksId": "aWZzLPhY4o0C", + "barnesAndNobleId": "1100307790", + "appleBooksId": "id395211", + "isbNs": [ + { + "value": "0395272238", + "format": "Isbn10" + }, + { + "value": "9780395272237", + "format": "Isbn13" + } + ], + "contributors": [], + "ratings": [ + { + "value": 4.36, + "maxValue": 5, + "voteCount": 2345678 + }, + { + "value": 4.7, + "maxValue": 5, + "voteCount": 87654 + } + ], + "id": { + "value": "32b336e8-dafc-4a08-9dec-9454e66dd55d" + } } ``` @@ -92,34 +227,9 @@ GET /books ```json [ - { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Yummy Menu", - "description": "A menu with yummy food", - "averageRating": null, - "sections": [ - { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Appetizers", - "description": "Starters", - "items": [ - { - "id": "00000000-0000-0000-0000-000000000000", - "name": "Fried Pickles", - "description": "Deep fried pickles" - } - ] - } - ], - "hostId": "00000000-0000-0000-0000-000000000000", - "dinnerIds": [ - "00000000-0000-0000-0000-000000000000", - ], - "menuReviewIds": [ - "00000000-0000-0000-0000-000000000000", - ], - "createdDateTime": "2020-01-01T00:00:00.0000000Z", - "updatedDateTime": "2020-01-01T00:00:00.0000000Z" + { + "created": "2020-01-01T00:00:00.0000000Z", + "updated": "2020-01-01T00:00:00.0000000Z" } ] ``` \ No newline at end of file diff --git a/docs/technical/domain/Aggregates.WrittenContentLibrary.md b/docs/technical/domain/Aggregates.WrittenContentLibrary.md index 8e8da241..7e533671 100644 --- a/docs/technical/domain/Aggregates.WrittenContentLibrary.md +++ b/docs/technical/domain/Aggregates.WrittenContentLibrary.md @@ -25,7 +25,6 @@ class Book Optional libraryThingId, Optional googleBooksId, Optional barnesAndNobleId, - Optional koboId, Optional appleBooksId, List isbns, List contributors, @@ -85,7 +84,6 @@ class Book "libraryThingId": "3203347", "googleBooksId": "aWZzLPhY4o0C", "barnesAndNobleId": "1100307790", - "koboId": "the-fellowship-of-the-ring", "appleBooksId": "id395211", "isbns": [ { diff --git a/docs/technical/requests/books/Add.http b/docs/technical/requests/books/Add.http index 5efcf86c..eacdfed3 100644 --- a/docs/technical/requests/books/Add.http +++ b/docs/technical/requests/books/Add.http @@ -45,13 +45,12 @@ Content-Type: application/json }, "asin": "B007978NPG", "goodreadsId": "3", - "lccn": "2001025199", - "oclcNumber": "48494995", + "lccn": "54009621", + "oclcNumber": "ocm00012345", "openLibraryId": "OL7603910M", "libraryThingId": "3203347", "googleBooksId": "aWZzLPhY4o0C", "barnesAndNobleId": "1100307790", - "koboId": "the-fellowship-of-the-ring", "appleBooksId": "id395211", "isbns": [ { diff --git a/src/Lumina.Application/Common/Models/Books/BookDto.cs b/src/Lumina.Application/Common/Models/Books/BookDto.cs index 48b7e486..d6fada21 100644 --- a/src/Lumina.Application/Common/Models/Books/BookDto.cs +++ b/src/Lumina.Application/Common/Models/Books/BookDto.cs @@ -21,7 +21,6 @@ public record BookDto( string? LibraryThingId, string? GoogleBooksId, string? BarnesAndNobleId, - string? KoboId, string? AppleBooksId, List ISBNs, List Contributors, diff --git a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommand.cs b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommand.cs index 3e6885e8..bae3dbb5 100644 --- a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommand.cs +++ b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommand.cs @@ -26,7 +26,6 @@ public record AddBookCommand( string? LibraryThingId, string? GoogleBooksId, string? BarnesAndNobleId, - string? KoboId, string? AppleBooksId, List ISBNs, List Contributors, diff --git a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandHandler.cs b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandHandler.cs index 67c32952..3ddf8b1a 100644 --- a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandHandler.cs +++ b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandHandler.cs @@ -28,6 +28,7 @@ public class AddBookCommandHandler : IRequestHandler public async ValueTask> Handle(AddBookCommand request, CancellationToken cancellationToken) { + // TODO: update Api.Book.md documentation when the functionality is fully implemented List contributorIds = new(); foreach(var mediaContributor in request.Contributors) { @@ -129,7 +130,6 @@ public class AddBookCommandHandler : IRequestHandler.FromNullable(request.LibraryThingId), Optional.FromNullable(request.GoogleBooksId), Optional.FromNullable(request.BarnesAndNobleId), - Optional.FromNullable(request.KoboId), Optional.FromNullable(request.AppleBooksId), domainIsbns, contributorIds, diff --git a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandValidator.cs b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandValidator.cs index 35f1b799..56496891 100644 --- a/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandValidator.cs +++ b/src/Lumina.Application/Core/WrittenContentLibrary/BooksLibrary/Books/Commands/AddBookCommandValidator.cs @@ -128,11 +128,10 @@ public class AddBookCommandValidator : AbstractValidator .Matches(@"^\d+$").When(x => x.GoodreadsId is not null) .WithMessage(Errors.WrittenContent.GoodreadsIdMustBeNumeric.Code); RuleFor(x => x.LCCN) - .Length(12).WithMessage(Errors.WrittenContent.LccnMustBe12CharactersLong.Code) - .Matches(@"^[a-z]{0,3}\d{8}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code) + .Matches(@"^[a-z]{0,3}\d{8,10}$").WithMessage(Errors.WrittenContent.InvalidLccnFormat.Code) .When(x => x.LCCN is not null); RuleFor(x => x.OCLCNumber) - .Matches(@"^(ocm\d{8} |ocn\d{9,}|\(OCoLC\)\d+)$").When(x => x.OCLCNumber is not null) + .Matches(@"^(ocm\d{8}|ocn\d{9,}|on\d{10,}|\(OCoLC\)\d{8,}|\d{8,})$").When(x => x.OCLCNumber is not null) .WithMessage(Errors.WrittenContent.InvalidOclcFormat.Code); RuleFor(x => x.OpenLibraryId) .Matches(@"^OL[1-9]\d*[AMW]$").When(x => x.OpenLibraryId is not null) @@ -148,10 +147,6 @@ public class AddBookCommandValidator : AbstractValidator .Length(10).WithMessage(Errors.WrittenContent.BarnesAndNoblesIdMustBe10CharactersLong.Code) .Matches(@"^\d{10}$").WithMessage(Errors.WrittenContent.InvalidBarnesAndNoblesIdFormat.Code) .When(x => x.BarnesAndNobleId is not null); - RuleFor(x => x.KoboId) - .Matches(@"^\d+$").WithMessage(Errors.WrittenContent.KoboIdMustBeNumeric.Code) - .Length(3, 5).WithMessage(Errors.WrittenContent.KoboIdMustBeBetween3And5CharactersLong.Code) - .When(x => x.KoboId is not null); RuleFor(x => x.AppleBooksId) .Matches(@"^id\d+$").When(x => x.AppleBooksId is not null) .WithMessage(Errors.WrittenContent.InvalidAppleBooksIdFormat.Code); diff --git a/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs b/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs index 0558ecc9..a46e2ca3 100644 --- a/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs +++ b/src/Lumina.Domain/Common/Errors/Errors.WrittenContent.cs @@ -21,7 +21,6 @@ public static partial class Errors public static Error TheBookIsNotInTheSeries => Error.Forbidden(nameof(TheBookIsNotInTheSeries)); public static Error AsinMustBe10CharactersLong => Error.Validation(nameof(AsinMustBe10CharactersLong)); public static Error GoodreadsIdMustBeNumeric => Error.Validation(nameof(GoodreadsIdMustBeNumeric)); - public static Error LccnMustBe12CharactersLong => Error.Validation(nameof(LccnMustBe12CharactersLong)); public static Error InvalidLccnFormat => Error.Validation(nameof(InvalidLccnFormat)); public static Error InvalidOclcFormat => Error.Validation(nameof(InvalidOclcFormat)); public static Error InvalidOpenLibraryId => Error.Validation(nameof(InvalidOpenLibraryId)); @@ -30,8 +29,6 @@ public static partial class Errors public static Error InvalidGoogleBooksIdFormat => Error.Validation(nameof(InvalidGoogleBooksIdFormat)); public static Error BarnesAndNoblesIdMustBe10CharactersLong => Error.Validation(nameof(BarnesAndNoblesIdMustBe10CharactersLong)); public static Error InvalidBarnesAndNoblesIdFormat => Error.Validation(nameof(InvalidBarnesAndNoblesIdFormat)); - public static Error KoboIdMustBeNumeric => Error.Validation(nameof(KoboIdMustBeNumeric)); - public static Error KoboIdMustBeBetween3And5CharactersLong => Error.Validation(nameof(KoboIdMustBeBetween3And5CharactersLong)); public static Error InvalidAppleBooksIdFormat => Error.Validation(nameof(InvalidAppleBooksIdFormat)); public static Error PublisherMustBeMaximum100CharactersLong => Error.Validation(nameof(PublisherMustBeMaximum100CharactersLong)); public static Error PageCountMustBeGreaterThanZero => Error.Validation(nameof(PageCountMustBeGreaterThanZero)); diff --git a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs index 565d83bf..30f5b44e 100644 --- a/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs +++ b/src/Lumina.Domain/Core/Aggregates/WrittenContentLibrary/BookLibraryAggregate/Book.cs @@ -90,11 +90,6 @@ public sealed class Book : AggregateRoot /// public Optional BarnesAndNobleId { get; private set; } - /// - /// Gets the Kobo ID of the book. - /// - public Optional KoboId { get; private set; } - /// /// Gets the Apple Books ID of the book. /// @@ -143,7 +138,6 @@ public sealed class Book : AggregateRoot /// The optional LibraryThing ID of the book. /// The optional Google Books ID of the book. /// The optional Barnes & Noble ID of the book. - /// The optional Kobo ID of the book. /// The optional Apple Books ID of the book. /// The list of ISBNs of the book. /// The list of media contributors of the book. @@ -163,7 +157,6 @@ public sealed class Book : AggregateRoot Optional libraryThingId, Optional googleBooksId, Optional barnesAndNobleId, - Optional koboId, Optional appleBooksId, List isbns, List contributors, @@ -183,7 +176,6 @@ public sealed class Book : AggregateRoot LibraryThingId = libraryThingId; GoogleBooksId = googleBooksId; BarnesAndNobleId = barnesAndNobleId; - KoboId = koboId; AppleBooksId = appleBooksId; _isbns = isbns; _contributors = contributors; @@ -218,7 +210,6 @@ public sealed class Book : AggregateRoot /// The optional LibraryThing ID of the book. /// The optional Google Books ID of the book. /// The optional Barnes & Noble ID of the book. - /// The optional Kobo ID of the book. /// The optional Apple Books ID of the book. /// The list of ISBNs of the book. /// The list of media contributors of the book. @@ -240,7 +231,6 @@ public sealed class Book : AggregateRoot Optional libraryThingId, Optional googleBooksId, Optional barnesAndNobleId, - Optional koboId, Optional appleBooksId, List isbns, List contributors, @@ -262,7 +252,6 @@ public sealed class Book : AggregateRoot libraryThingId, googleBooksId, barnesAndNobleId, - koboId, appleBooksId, isbns, contributors, @@ -286,7 +275,6 @@ public sealed class Book : AggregateRoot /// The optional LibraryThing ID of the book. /// The optional Google Books ID of the book. /// The optional Barnes & Noble ID of the book. - /// The optional Kobo ID of the book. /// The optional Apple Books ID of the book. /// The list of ISBNs of the book. /// The list of media contributors of the book. @@ -309,7 +297,6 @@ public sealed class Book : AggregateRoot Optional libraryThingId, Optional googleBooksId, Optional barnesAndNobleId, - Optional koboId, Optional appleBooksId, List isbns, List contributors, @@ -331,7 +318,6 @@ public sealed class Book : AggregateRoot libraryThingId, googleBooksId, barnesAndNobleId, - koboId, appleBooksId, isbns, contributors, diff --git a/src/Lumina.Presentation.Api/Common/Contracts/Books/AddBookRequest.cs b/src/Lumina.Presentation.Api/Common/Contracts/Books/AddBookRequest.cs index eb953285..c8fb1c1c 100644 --- a/src/Lumina.Presentation.Api/Common/Contracts/Books/AddBookRequest.cs +++ b/src/Lumina.Presentation.Api/Common/Contracts/Books/AddBookRequest.cs @@ -23,7 +23,6 @@ public record AddBookRequest( string? LibraryThingId, string? GoogleBooksId, string? BarnesAndNobleId, - string? KoboId, string? AppleBooksId, List ISBNs, List Contributors,