diff --git a/README.md b/README.md index 8bedced..756a0d5 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,226 @@ -# OpenLibraryWS_Wrapper +# OpenLibraryWS_wrapper +## Summary + +This project proposes a Web Service wrapping the [OpenLibrary](https://openlibrary.org/). This is an archive of books and editions and it proposes a web api. This work here is a wrapper in order to simplify the use of this api, with less routes, and also to be interchangeable with another web service that will be issued shortly, owning its proper database of books. +Its purpose is mainly and only to be used by my students in order to practice a little bit _continuous integration_ and _continuous deployment_. + +## Table of Contents + +[Documentation](#documentation) +[Getting Started](#getting-started) +[Where are we now?](#where-are-we-now) +[Usage](#usage) +[Running the tests](#running-the-tests) +[Known issues and limitations](#known-issues-and-limitations) +[Built with](#built-with) +[Authors](#authors) +[Acknowledgements](#acknowledgements) + +## Documentation + +There is no other documentation than this ```ReadMe```, at least for now. +But here are some useful informations. +### Package diagram +```mermaid +flowchart LR + + DTOAbstractLayer -.-> LibraryDTO + JSonReader -.-> LibraryDTO + OpenLibraryClient -.-> DTOAbstractLayer + OpenLibraryClient -.-> JSonReader + StubbedDTO -.-> DTOAbstractLayer + StubbedDTO -.-> JSonReader + OpenLibraryWrapper -.-> OpenLibraryClient + OpenLibraryWrapper -.-> StubbedDTO +``` +This work contains some projects: +- ```LibraryDTO```: contains all **DTO** (_Data Transfer Object_) used by the web service(s) of this project +- ```DTOAbstractLayer```: defines a unique interface (```IDtoManager```) for all objects that can be used to make requests +- ```JSonReader```: contains some tools simplifying the parsing of json request results coming from ```OpenLibrary API``` +- ```StubbedDTO```: is only used for testing the preceding packages. It contains some json files copied from ```OpenLibrary API``` request results +- ```OpenLibraryClient```: this is the wrapper of ```OpenLibrary API```. It implements ```IDtoManager``` and uses ```OpenLibrary API``` requests to get books and authors. +- ```OpenLibraryWrapper```: defines our Web Service and its routes. + +### Routes of ```OpenLibraryWrapper``` web service: +There are very few routes: + - **get books by title**: allows to get books containing a particular string in their titles. + ``` + book/getbooksbytitle?title=ne&index=0&count=5 + book/getbooksbytitle?title=ne&index=0&count=5&sort=old + ``` + - **get books by author**: allows to get books containing a particular string in the author names or alternate names. + ``` + book/getbooksbyauthor?name=al&index=0&count=5 + book/getbooksbyauthor?name=al&index=0&count=5&sort=old + ``` + - **get books by author id**: allows to get books of a particular author by giving its id. + ``` + book/getbooksbyauthorid?id=OL1846639A&index=0&count=5 + book/getbooksbyauthorid?id=OL1846639A&index=0&count=5&sort=old + ``` + - **get authors by name**: allows to get authors whose name (or alternate names) contains a particular string. + ``` + book/getauthorsbyname?name=al&index=0&count=5 + book/getauthorsbyname?name=al&index=0&count=5&sort=name + ``` + - **get book by isbn**: allows to get a book by giving its isbn. + ``` + book/getBookByIsbn/9782330033118 + ``` + - **get book by id**: allows to get a book by giving its id. + ``` + book/getBookById/OL25910297M + ``` + - **get author by id**: allows to get an author by giving its id. + ``` + book/getAuthorById/OL1846639A + ``` + +### Class diagram + +For what it's worth... +You will probably not need it... +Nevertheless, it shows how **DTO** classes are working with each other. + +```mermaid +classDiagram +direction LR +class BookDTO { + +Id : string + +Title : string + +Publishers : List~string~ + +PublishDate : DateTime + +ISBN13 : string + +Series : List~string~ + +NbPages : int + +Format : string + +ImageSmall : string + +ImageMedium : string + +ImageLarge : string +} + +class Languages { + <> + Unknown, + French, +} + +class WorkDTO { + +Id : string + +Description : string + +Title : string + +Subjects : List~string~ +} + +class ContributorDTO { + +Name : string + +Role : string +} + +class AuthorDTO { + +Id : string + +Name : string + +ImageSmall : string + +ImageMedium : string + +ImageLarge : string + +Bio : string + +AlternateNames : List~string~ + +BirthDate : DateTime? + +DeathDate : DateTime? +} + +class LinkDTO { + +Title : string + +Url : string +} + +class RatingsDTO { + +Average : float + +Count : int +} + +BookDTO --> "1" Languages : Language +BookDTO --> "*" ContributorDTO : Contributors +AuthorDTO --> "*" LinkDTO : Links +WorkDTO --> "*" AuthorDTO : Authors +WorkDTO --> "1" RatingsDTO : Ratings +BookDTO --> "*" AuthorDTO : Authors +BookDTO --> "*" WorkDTO : Works +``` + +## Getting Started + +If you want to test this project locally, simply ```git clone``` this project, and open the solution ```Sources/OpenLibraryWS_Wrapper.sln```. + +### Prerequisites +- Visual Studio 2019 or Visual Studio for Mac +- .NET 7.0 or higher +### Setup +Just ```git clone``` and build the solution. + +## Where are we now? + +Well, some parts are missing for pedagogical purposes... +- There is no CI/CD file. You will have to prepare it all by yourself. +- There is no files allowing to generate documentation (doxygen documentation for the code or swagger for the web api routes) +- There is no ```Dockerfile```. + +Moreover, a lot of stuff could be enhanced, but I do not have time for this: +- there are too few unit tests +- there are too few comments in code +- the second version of the web service with its own database is not ready yet (but soon hopefully). + +## Running the tests +You can run some unit tests but there are few. The unit tests project is ```OpenLibraryWrapper_UT```. +Run them in Visual Studio or using the command ```dotnet test```. + +## Known issues and limitations +- CI/CD is not set yet. +- Documentation is not deployed. + +## Built with +.NET and Visual Studio for Mac + +## Next steps +This project should be enhanced with _Continuous Integration_ and _Continuous Deployment_ pipelines. +Here are the different steps that should be added: +1. **build** job: +All the projects of the solution should be built and published. +In order to write this job, one could find useful information in: + - the [**code first documentation about CI build jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/build/) + - the [**dotnet official documentation**](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet) about .NET command lines. + To build and publish a .NET solution, you usually need to ```restore```, ```build``` and ```publish```. +2. **unit tests** job: +All the unit tests projects of the solution should be run. +In order to write this job, one could find useful information in: + - the [**code first documentation about CI unit tests jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/tests/) + - the [**dotnet official documentation**](https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet) about .NET command lines. + To run .NET unit tests projects, you usually need to ```restore``` and ```test```. +3. **continuous integration** job: +A code analysis should be run and exported to **Sonarqube**. +One can find useful information in: + - the [**code first documentation about CI unit tests jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/CI/codeInspection/) + - the [**SonarQube documentation**](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner-for-dotnet/) for .NET +4. **documentation** jobs: +Two different documentations should be published: + - **doxygen**: although very few comments are present in the source code, a doxygen documentation should be deployed. + It could look like this: + + And the footer could look like this: + + One could find useful information in: + - the [**code first documentation about doxygen jobs**](https://codefirst.iut.uca.fr/documentation/CodeFirst/docusaurus/GuidesTutorials/docs/CI-CD/DocJobs/doxygen/) + - the [**official doxygen documentation**](https://www.doxygen.nl/) + - **swagger**: the routes of the web service should be documented through a Swagger documentation. But nothing has been prepared in Web Service project. First, one should modify the .NET project to add Swagger documentation generation, and next modify the documentation job. + It could look like this: + + And the footer could look like this: + One could find useful information in: + - the [**documentation about how to integrate Swagger in a .NET project**](https://learn.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-7.0&tabs=visual-studio). + +## Authors +Marc Chevaldonné + +## Acknowledgements +Camille Petitalot and Cédric Bouhours \ No newline at end of file diff --git a/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj b/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj new file mode 100644 index 0000000..496da7a --- /dev/null +++ b/Sources/DtoAbstractLayer/DtoAbstractLayer.csproj @@ -0,0 +1,12 @@ + + + + net7.0 + enable + enable + + + + + + diff --git a/Sources/DtoAbstractLayer/IDtoManager.cs b/Sources/DtoAbstractLayer/IDtoManager.cs new file mode 100644 index 0000000..4edf2da --- /dev/null +++ b/Sources/DtoAbstractLayer/IDtoManager.cs @@ -0,0 +1,97 @@ +using LibraryDTO; + +namespace DtoAbstractLayer; + +/// +/// abstract layer for requests on Books Library +/// +public interface IDtoManager +{ + /// + /// get a book by specifying its id + /// + /// id of the Book to get + /// a Book with this id (or null if id is unknown) + Task GetBookById(string id); + + /// + /// get a book by specifying its isbn + /// + /// isbn of the Book to get + /// a Book with this isbn (or null if isbn is unknown) + Task GetBookByISBN(string isbn); + + /// + /// get books containing a substring in their titles + /// + /// the substring to look for in book titles + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// max count books + Task>> GetBooksByTitle(string title, int index, int count, string sort = ""); + + /// + /// get books of a particular author by giving the author id + /// + /// the id of the author + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// max count books + Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = ""); + + /// + /// get books of authors whose name (or alternate names) contains a particular substring + /// + /// name to look for in author names or alternate names + /// index of the page of resulting books + /// number of resulting books per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// max count books + Task>> GetBooksByAuthor(string author, int index, int count, string sort = ""); + + /// + /// get an author by specifying its id + /// + /// id of the Author to get + /// an author with this id (or null if id is unknown) + Task GetAuthorById(string id); + + /// + /// get authors containing a substring in their names (or alternate names) + /// + /// the substring to look for in author names (or alternate names) + /// index of the page of resulting authors + /// number of resulting authors per page + /// sort criterium (not mandatory): + ///
    + ///
  • ```name```: sort authors by names in alphabetical order,
  • + ///
  • ```name_reverse```: sort authors by names in reverse alphabetical order,
  • + ///
+ /// + /// max count authors + Task>> GetAuthorsByName(string substring, int index, int count, string sort = ""); +} + diff --git a/Sources/JsonReader/AuthorJsonReader.cs b/Sources/JsonReader/AuthorJsonReader.cs new file mode 100644 index 0000000..39de3ec --- /dev/null +++ b/Sources/JsonReader/AuthorJsonReader.cs @@ -0,0 +1,53 @@ +using System; +using LibraryDTO; +using Newtonsoft.Json.Linq; +using System.Globalization; + +namespace JsonReader +{ + public static class AuthorJsonReader + { + public static AuthorDTO ReadAuthor(string json) + { + JObject o = JObject.Parse(json); + string bioTokenAsString = null; + if(o.TryGetValue("bio", out JToken? bioToken)) + { + if(bioToken.Type == JTokenType.String) + { + bioTokenAsString = (string)bioToken; + } + else + { + var bioTokenValue = o["bio"]?["value"]; + bioTokenAsString = (string)bioTokenValue; + } + } + + AuthorDTO author = new AuthorDTO + { + Id = (string)o["key"], + Name = (string)o["name"], + Bio = bioTokenAsString, + BirthDate = o.TryGetValue("birth_date", out JToken? bd) ? DateTime.ParseExact((string)bd, "d MMMM yyyy", CultureInfo.InvariantCulture) : null, + DeathDate = o.TryGetValue("death_date", out JToken? dd) ? DateTime.ParseExact((string)dd, "d MMMM yyyy", CultureInfo.InvariantCulture) : null, + Links = o.TryGetValue("links", out JToken? links) ? links.Select(l => new LinkDTO { Title = (string)l["title"], Url = (string)l["url"] }).ToList() : new List(), + AlternateNames = o.TryGetValue("alternate_names", out JToken? altNames) ? altNames.Select(alt => (string)alt).ToList() : new List() + }; + return author; + } + + public static Tuple> GetAuthorsByName(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var authors = o["docs"].Select(doc => new AuthorDTO + { + Id = $"/authors/{(string)doc["key"]}", + Name = (string)doc["name"], + }); + return Tuple.Create(numFound, authors); + } + } +} + diff --git a/Sources/JsonReader/BookJsonReader.cs b/Sources/JsonReader/BookJsonReader.cs new file mode 100644 index 0000000..a752e5a --- /dev/null +++ b/Sources/JsonReader/BookJsonReader.cs @@ -0,0 +1,82 @@ +using System.Globalization; +using LibraryDTO; +using Newtonsoft.Json.Linq; + +namespace JsonReader; + +public static class BookJsonReader +{ + static Dictionary languages = new Dictionary() + { + [@"/languages/fre"] = Languages.French, + [@"/languages/eng"] = Languages.English, + ["fre"] = Languages.French, + ["eng"] = Languages.English, + [""] = Languages.Unknown + }; + + public static BookDTO ReadBook(string json) + { + JObject o = JObject.Parse(json); + var l = o["languages"]?.FirstOrDefault(""); + Languages lang = l != null ? languages[(string)l["key"]] : Languages.Unknown; + Tuple pubDateFormat = lang switch + { + Languages.French => Tuple.Create("d MMMM yyyy", CultureInfo.GetCultureInfo("fr-FR")), + Languages.Unknown => Tuple.Create("MMM dd, yyyy", CultureInfo.InvariantCulture) + }; + + BookDTO book = new BookDTO + { + Id = (string)o["key"], + Title = (string)o["title"], + Publishers = o["publishers"].Select(p => (string)p).ToList(), + PublishDate = DateTime.TryParseExact((string)o["publish_date"], pubDateFormat.Item1, pubDateFormat.Item2, DateTimeStyles.None, out DateTime date) ? date : new DateTime((int)o["publish_date"], 12, 31), + ISBN13 = (string)o["isbn_13"][0], + NbPages = (int)o["number_of_pages"], + Language = lang, + Format = o.TryGetValue("physical_format", out JToken? f) ? (string)f : null, + Works = o["works"].Select(w => new WorkDTO { Id = (string)w["key"] }).ToList(), + Contributors = o.TryGetValue("contributors", out JToken? contr) ? contr.Select(c => new ContributorDTO { Name = (string)c["name"], Role = (string)c["role"] }).ToList() : new List(), + Authors = o["authors"]?.Select(a => new AuthorDTO { Id = (string)a["key"] }).ToList() + }; + if(book.Authors == null) + { + book.Authors = new List(); + } + return book; + } + + public static Tuple> GetBooksByAuthor(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var books = o["docs"].Select(doc => new BookDTO + { + Id = (string)(doc["seed"].First()), + Title = (string)doc["title"], + ISBN13 = (string)(doc["isbn"].First()), + Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/")) + .Select(s => new AuthorDTO { Id = (string)s }).ToList(), + Language = languages.GetValueOrDefault((string)(doc["language"].First())) + }); + return Tuple.Create(numFound, books); + } + + public static Tuple> GetBooksByTitle(string json) + { + JObject o = JObject.Parse(json); + long numFound = (long)o["numFound"]; + var books = o["docs"].Select(doc => new BookDTO + { + Id = (string)(doc["seed"].First()), + Title = (string)doc["title"], + ISBN13 = (string)(doc["isbn"].First()), + Authors = doc["seed"].Where(s => ((string)s).StartsWith("/authors/")) + .Select(s => new AuthorDTO { Id = (string)s }).ToList(), + Language = languages.GetValueOrDefault((string)(doc["language"].First())) + }); + return Tuple.Create(numFound, books); + } +} + diff --git a/Sources/JsonReader/JsonReader.csproj b/Sources/JsonReader/JsonReader.csproj new file mode 100644 index 0000000..8e77096 --- /dev/null +++ b/Sources/JsonReader/JsonReader.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/Sources/JsonReader/WorkJsonReader.cs b/Sources/JsonReader/WorkJsonReader.cs new file mode 100644 index 0000000..86cbbd6 --- /dev/null +++ b/Sources/JsonReader/WorkJsonReader.cs @@ -0,0 +1,39 @@ +using System; +using LibraryDTO; +using Newtonsoft.Json.Linq; +using System.Globalization; + +namespace JsonReader +{ + public static class WorkJsonReader + { + public static WorkDTO ReadWork(string json, string ratingsJson) + { + JObject o = JObject.Parse(json); + JObject r = JObject.Parse(ratingsJson); + var ratingsDto = new RatingsDTO(); + if(r["summary"]["average"].Type != JTokenType.Float) + { + ratingsDto.Average = -1; + ratingsDto.Count = 0; + } + else + { + ratingsDto.Average = (float)r["summary"]["average"]; + ratingsDto.Count = (int)r["summary"]["count"]; + } + + WorkDTO work = new WorkDTO + { + Id = (string)o["key"], + Title = (string)o["title"], + Authors = o["authors"].Select(a => new AuthorDTO { Id = (string)a["author"]["key"] }).ToList(), + Description = o.TryGetValue("description", out JToken? descr) ? (string)descr : null, + Subjects = o.TryGetValue("subjects", out JToken? subjects) ? subjects.Select(s => (string)s).ToList() : new List(), + Ratings = ratingsDto + }; + return work; + } + } +} + diff --git a/Sources/LibraryDTO/AuthorDTO.cs b/Sources/LibraryDTO/AuthorDTO.cs new file mode 100644 index 0000000..22376e7 --- /dev/null +++ b/Sources/LibraryDTO/AuthorDTO.cs @@ -0,0 +1,18 @@ +using System; +namespace LibraryDTO +{ + public class AuthorDTO + { + public string Id { get; set; } + public string Name { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/a/olid/{Id.Substring(Id.LastIndexOf("/"))}-L.jpg"; + public string Bio { get; set; } + public List AlternateNames { get; set; } = new List(); + public List Links { get; set; } + public DateTime? BirthDate { get; set; } + public DateTime? DeathDate { get; set; } + } +} + diff --git a/Sources/LibraryDTO/BookDTO.cs b/Sources/LibraryDTO/BookDTO.cs new file mode 100644 index 0000000..a260ae0 --- /dev/null +++ b/Sources/LibraryDTO/BookDTO.cs @@ -0,0 +1,23 @@ +using System; +namespace LibraryDTO +{ + public class BookDTO + { + public string Id { get; set; } + public string Title { get; set; } + public List Publishers { get; set; } = new List(); + public DateTime PublishDate { get; set; } + public string ISBN13 { get; set; } + public List Series { get; set; } = new List(); + public int NbPages { get; set; } + public string Format { get; set; } + public Languages Language { get; set; } + public List Contributors { get; set; } + public string ImageSmall => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-S.jpg"; + public string ImageMedium => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-M.jpg"; + public string ImageLarge => $"https://covers.openlibrary.org/b/isbn/{ISBN13}-L.jpg"; + public List Works { get; set; } = new List(); + public List Authors { get; set; } = new List(); + } +} + diff --git a/Sources/LibraryDTO/ContributorDTO.cs b/Sources/LibraryDTO/ContributorDTO.cs new file mode 100644 index 0000000..beab5d1 --- /dev/null +++ b/Sources/LibraryDTO/ContributorDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class ContributorDTO + { + public string Name { get; set; } + public string Role { get; set; } + } +} + diff --git a/Sources/LibraryDTO/Languages.cs b/Sources/LibraryDTO/Languages.cs new file mode 100644 index 0000000..fcf51b5 --- /dev/null +++ b/Sources/LibraryDTO/Languages.cs @@ -0,0 +1,11 @@ +using System; +namespace LibraryDTO +{ + public enum Languages + { + Unknown, + French, + English + } +} + diff --git a/Sources/LibraryDTO/LibraryDTO.csproj b/Sources/LibraryDTO/LibraryDTO.csproj new file mode 100644 index 0000000..0b93a96 --- /dev/null +++ b/Sources/LibraryDTO/LibraryDTO.csproj @@ -0,0 +1,16 @@ + + + + net7.0 + enable + enable + + + + 4 + + + true + 4 + + diff --git a/Sources/LibraryDTO/LinkDTO.cs b/Sources/LibraryDTO/LinkDTO.cs new file mode 100644 index 0000000..336909c --- /dev/null +++ b/Sources/LibraryDTO/LinkDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class LinkDTO + { + public string Title { get; set; } + public string Url { get; set; } + } +} + diff --git a/Sources/LibraryDTO/RatingsDTO.cs b/Sources/LibraryDTO/RatingsDTO.cs new file mode 100644 index 0000000..f15e5eb --- /dev/null +++ b/Sources/LibraryDTO/RatingsDTO.cs @@ -0,0 +1,10 @@ +using System; +namespace LibraryDTO +{ + public class RatingsDTO + { + public float Average { get; set; } + public int Count { get; set; } + } +} + diff --git a/Sources/LibraryDTO/WorkDTO.cs b/Sources/LibraryDTO/WorkDTO.cs new file mode 100644 index 0000000..2c41813 --- /dev/null +++ b/Sources/LibraryDTO/WorkDTO.cs @@ -0,0 +1,14 @@ +using System; +namespace LibraryDTO +{ + public class WorkDTO + { + public string Id { get; set; } + public string Description { get; set; } + public string Title { get; set; } + public List Subjects { get; set; } = new List(); + public List Authors { get; set; } = new List(); + public RatingsDTO Ratings { get; set; } + } +} + diff --git a/Sources/OpenLibraryClient/OpenLibClientAPI.cs b/Sources/OpenLibraryClient/OpenLibClientAPI.cs new file mode 100644 index 0000000..eb4a493 --- /dev/null +++ b/Sources/OpenLibraryClient/OpenLibClientAPI.cs @@ -0,0 +1,104 @@ +using System; +using System.Data.SqlTypes; +using System.Net; +using System.Text.Json; +using DtoAbstractLayer; +using JsonReader; +using LibraryDTO; +using static System.Net.WebRequestMethods; + +namespace OpenLibraryClient; + +public class OpenLibClientAPI : IDtoManager +{ + const string BasePath = @"https://openlibrary.org/"; + const string SearchAuthorPrefix = @"search/authors.json?q="; + const string SearchBookTitlePrefix = @"search.json?title="; + const string SearchBookByAuthorPrefix = @"search.json?author="; + const string AuthorPrefix = @"authors/"; + const string BookPrefix = @"books/"; + const string IsbnPrefix = @"isbn/"; + HttpClient client = new HttpClient(); + JsonSerializerOptions SerializerOptions { get; set; } = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + WriteIndented = true + }; + + private async Task GetElement(string route, Func deserializer) + { + try + { + T result = default(T); + Uri uri = new Uri (route, UriKind.RelativeOrAbsolute); + HttpResponseMessage response = await client.GetAsync (uri); + if (response.IsSuccessStatusCode) + { + string content = await response.Content.ReadAsStringAsync (); + result = deserializer(content); + } + return result; + } + catch(Exception exc) + { + throw new WebException($"The route {route} seems to be invalid"); + } + } + + + + public async Task GetAuthorById(string id) + { + string route = $"{BasePath}{AuthorPrefix}{id}.json"; + return await GetElement(route, json => AuthorJsonReader.ReadAuthor(json)); + } + + public async Task>> GetAuthorsByName(string substring, int index, int count, string sort = "") + { + string searchedString = substring.Trim().Replace(" ", "+"); + string route = $"{BasePath}{SearchAuthorPrefix}{searchedString}" + .AddPagination(index, count) + .AddSort(sort); + return await GetElement>>(route, json => AuthorJsonReader.GetAuthorsByName(json)); + } + + public async Task GetBookById(string id) + { + string route = $"{BasePath}{BookPrefix}{id}.json"; + return await GetElement(route, json => BookJsonReader.ReadBook(json)); + } + + public async Task GetBookByISBN(string isbn) + { + string route = $"{BasePath}{IsbnPrefix}{isbn}.json"; + return await GetElement(route, json => BookJsonReader.ReadBook(json)); + } + + public async Task>> GetBooksByAuthor(string author, int index, int count, string sort = "") + { + string searchedString = author.Trim().Replace(" ", "+"); + string route = $"{BasePath}{SearchBookByAuthorPrefix}{searchedString}" + .AddPagination(index, count) + .AddSort(sort); + return await GetElement>>(route, json => BookJsonReader.GetBooksByAuthor(json)); + } + + public async Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") + { + string searchedString = authorId.Trim().Replace(" ", "+"); + string route = $"{BasePath}{SearchAuthorPrefix}{searchedString}" + .AddPagination(index, count) + .AddSort(sort); + return await GetElement>>(route, json => BookJsonReader.GetBooksByAuthor(json)); + } + + public async Task>> GetBooksByTitle(string title, int index, int count, string sort = "") + { + string searchedString = title.Trim().Replace(" ", "+"); + string route = $"{BasePath}{SearchBookTitlePrefix}{searchedString}" + .AddPagination(index, count) + .AddSort(sort); + return await GetElement>>(route, json => BookJsonReader.GetBooksByTitle(json)); + } +} + diff --git a/Sources/OpenLibraryClient/OpenLibraryClient.csproj b/Sources/OpenLibraryClient/OpenLibraryClient.csproj new file mode 100644 index 0000000..81f2f6d --- /dev/null +++ b/Sources/OpenLibraryClient/OpenLibraryClient.csproj @@ -0,0 +1,14 @@ + + + + net7.0 + enable + enable + + + + + + + + diff --git a/Sources/OpenLibraryClient/RouteExtensions.cs b/Sources/OpenLibraryClient/RouteExtensions.cs new file mode 100644 index 0000000..6a49a11 --- /dev/null +++ b/Sources/OpenLibraryClient/RouteExtensions.cs @@ -0,0 +1,33 @@ +using System; +namespace OpenLibraryClient +{ + public static class RouteExtensions + { + public static string AddPagination(this string route, int index, int count) + { + if(index <= -1 || count<0) + { + return route; + } + string delimiter = route.Contains("?") ? "&" : "?"; + return $"{route}{delimiter}limit={count}&page={index+1}"; + } + + public static string AddSort(this string route, string sort) + { + string sortCriterium = sort switch + { + "new" => "new", + "old" => "old", + "random" => "random", + "key" => "key", + _ => null + }; + if(sortCriterium == null) return route; + + string delimiter = route.Contains("?") ? "&" : "?"; + return $"{route}{delimiter}sort={sortCriterium}"; + } + } +} + diff --git a/Sources/OpenLibraryWS_Wrapper.sln b/Sources/OpenLibraryWS_Wrapper.sln new file mode 100644 index 0000000..cc2c738 --- /dev/null +++ b/Sources/OpenLibraryWS_Wrapper.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1705.7 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryWrapper", "OpenLibraryWrapper\OpenLibraryWrapper.csproj", "{EF0DED5C-7559-4D43-A30B-AE916FCDA078}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{0D260EDC-4F17-4BA4-9306-B6FEC6E5E394}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryWrapper_UT", "OpenLibraryWrapper_UT\OpenLibraryWrapper_UT.csproj", "{B12BEDA7-EC41-417B-9C28-113A8ED87F35}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibraryDTO", "LibraryDTO\LibraryDTO.csproj", "{F59D46BA-6734-464E-8AC4-759BEFB87973}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StubbedDTO", "StubbedDTO\StubbedDTO.csproj", "{3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DtoAbstractLayer", "DtoAbstractLayer\DtoAbstractLayer.csproj", "{43E49F05-E257-441B-B5E4-C82DBE4DDF1A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JsonReader", "JsonReader\JsonReader.csproj", "{4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5C6B8D83-705A-4BBD-BBA0-A86ACB370B33}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenLibraryClient", "OpenLibraryClient\OpenLibraryClient.csproj", "{3A429457-D882-44E3-B65E-107554C2E91F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF0DED5C-7559-4D43-A30B-AE916FCDA078}.Release|Any CPU.Build.0 = Release|Any CPU + {B12BEDA7-EC41-417B-9C28-113A8ED87F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B12BEDA7-EC41-417B-9C28-113A8ED87F35}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B12BEDA7-EC41-417B-9C28-113A8ED87F35}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B12BEDA7-EC41-417B-9C28-113A8ED87F35}.Release|Any CPU.Build.0 = Release|Any CPU + {F59D46BA-6734-464E-8AC4-759BEFB87973}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F59D46BA-6734-464E-8AC4-759BEFB87973}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F59D46BA-6734-464E-8AC4-759BEFB87973}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F59D46BA-6734-464E-8AC4-759BEFB87973}.Release|Any CPU.Build.0 = Release|Any CPU + {3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3CB3D741-DF5C-4C4A-82C2-5BFC212211AD}.Release|Any CPU.Build.0 = Release|Any CPU + {43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43E49F05-E257-441B-B5E4-C82DBE4DDF1A}.Release|Any CPU.Build.0 = Release|Any CPU + {4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4EDEABC4-5AEC-4F7B-804C-3E3BA6EE29DF}.Release|Any CPU.Build.0 = Release|Any CPU + {3A429457-D882-44E3-B65E-107554C2E91F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3A429457-D882-44E3-B65E-107554C2E91F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3A429457-D882-44E3-B65E-107554C2E91F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3A429457-D882-44E3-B65E-107554C2E91F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2E40DC1C-BE57-48E8-B7C2-B9CFF589DB5B} + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {B12BEDA7-EC41-417B-9C28-113A8ED87F35} = {0D260EDC-4F17-4BA4-9306-B6FEC6E5E394} + EndGlobalSection +EndGlobal diff --git a/Sources/OpenLibraryWrapper/Controllers/BookController.cs b/Sources/OpenLibraryWrapper/Controllers/BookController.cs new file mode 100644 index 0000000..97a530a --- /dev/null +++ b/Sources/OpenLibraryWrapper/Controllers/BookController.cs @@ -0,0 +1,274 @@ +using System; +using DtoAbstractLayer; +using LibraryDTO; +using Microsoft.AspNetCore.Mvc; +using StubbedDTO; + +namespace OpenLibraryWrapper.Controllers +{ + [ApiController] + [Route("[controller]")] + public class BookController : ControllerBase + { + private readonly ILogger _logger; + + private IDtoManager DtoManager; + + public BookController(ILogger logger, IDtoManager dtoManager) + { + _logger = logger; + DtoManager = dtoManager; + } + + /// + /// Gets books of the collection matching a particular title + /// + /// part of a title to look for in book titles (case is ignored) + /// index of the page + /// number of elements per page + /// sort criterium of the resulting books: + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// + /// a collection of count (or less) books + /// + /// Sample requests: + /// + /// book/getbooksbytitle?title=ne&index=0&count=5 + /// book/getbooksbytitle?title=ne&index=0&count=5&sort=old + /// + /// + /// Returns count books at page index + /// no books within this range + [HttpGet("getBooksByTitle")] + [ProducesResponseType(typeof(Tuple>), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetBooksByTitle([FromQuery] string title, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "") + { + _logger.LogDebug("Get books by title"); + + var booksDto = (await DtoManager.GetBooksByTitle(title, index, count, sort)); + _logger.LogInformation($"{booksDto.Item1} books found"); + if(booksDto.Item1 == 0) + { + return NotFound(); + } + return Ok(booksDto); + } + + /// + /// Gets books of the collection whose of one the authors is matching a particular name + /// + /// part of a author name to look for in book authors (case is ignored) + /// index of the page + /// number of elements per page + /// sort criterium of the resulting books: + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// + /// a collection of count (or less) books + /// + /// Sample requests: + /// + /// book/getbooksbyauthor?name=al&index=0&count=5 + /// book/getbooksbyauthor?name=al&index=0&count=5&sort=old + /// + /// Note: + /// name is also looked for in alternate names of the authors + /// + /// Returns count books at page index + /// no books within this range + [HttpGet("getBooksByAuthor")] + [ProducesResponseType(typeof(Tuple>), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetBooksByAuthor([FromQuery] string name, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "") + { + _logger.LogDebug("Get books by author"); + + var booksDto = (await DtoManager.GetBooksByAuthor(name, index, count, sort)); + _logger.LogInformation($"{booksDto.Item1} books found"); + if(booksDto.Item1 == 0) + { + return NotFound(); + } + return Ok(booksDto); + } + + /// + /// Gets books of the collection of a particular author + /// + /// id of the author + /// index of the page + /// number of elements per page + /// sort criterium of the resulting books: + ///
    + ///
  • ```title```: sort books by titles in alphabetical order,
  • + ///
  • ```title_reverse```: sort books by titles in reverse alphabetical order,
  • + ///
  • ```new```: sort books by publishing dates, beginning with the most recents,
  • + ///
  • ```old```: sort books by publishing dates, beginning with the oldest
  • + ///
+ /// + /// + /// a collection of count (or less) books + /// + /// Sample requests: + /// + /// book/getbooksbyauthorid?id=OL1846639A&index=0&count=5 + /// book/getbooksbyauthorid?id=OL1846639A&index=0&count=5&sort=old + /// + /// + /// Returns count books at page index + /// no books within this range + [HttpGet("getBooksByAuthorId")] + [ProducesResponseType(typeof(Tuple>), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetBooksByAuthorId([FromQuery] string id, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "") + { + _logger.LogDebug("Get books by author id"); + + var booksDto = (await DtoManager.GetBooksByAuthorId(id, index, count, sort)); + _logger.LogInformation($"{booksDto.Item1} books found"); + if(booksDto.Item1 == 0) + { + return NotFound(); + } + return Ok(booksDto); + } + + /// + /// Gets authors of the collection matching a particular name + /// + /// name to look for in author names + /// index of the page + /// number of elements per page + /// sort criterium of the resulting authors: + ///
    + ///
  • ```name```: sort authors by names in alphabetical order,
  • + ///
  • ```name_reverse```: sort authors by names in reverse alphabetical order,
  • + ///
+ /// + /// + /// a collection of count (or less) authors + /// + /// Sample requests: + /// + /// book/getauthorsbyname?name=al&index=0&count=5 + /// book/getauthorsbyname?name=al&index=0&count=5&sort=name + /// + /// + /// Returns count authors at page index + /// no authors within this range + [HttpGet("getAuthorsByName")] + [ProducesResponseType(typeof(Tuple>), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetAuthorsByName([FromQuery] string name, [FromQuery] int index, [FromQuery] int count, [FromQuery] string sort = "") + { + _logger.LogDebug("Get authors by name"); + var authorsDto = (await DtoManager.GetAuthorsByName(name, index, count, sort)); + _logger.LogInformation($"{authorsDto.Item1} authors found"); + if(authorsDto.Item1 == 0) + { + return NotFound(); + } + return Ok(authorsDto); + } + + /// + /// Gets book by isbn + /// + /// isbn of the book to get + /// the book with the seeked isbn (or null) + /// + /// Sample requests: + /// + /// book/getBookByIsbn/9782330033118 + /// + /// + /// Returns the book with this isbn + /// no book found + [HttpGet("getBookByIsbn/{isbn?}")] + [ProducesResponseType(typeof(BookDTO), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetBookByIsbn(string isbn) + { + _logger.LogDebug("Get book by isbn"); + var bookDto = (await DtoManager.GetBookByISBN(isbn)); + if(bookDto == null) + { + _logger.LogInformation($"{isbn} not found"); + return NotFound(); + } + _logger.LogInformation($"{bookDto.Title} found"); + return Ok(bookDto); + } + + /// + /// Gets book by id + /// + /// id of the book to get + /// the book with the seeked id (or null) + /// + /// Sample requests: + /// + /// book/getBookById/OL25910297M + /// + /// + /// Returns the book with this id + /// no book found + [HttpGet("getBookById/{id?}")] + [ProducesResponseType(typeof(BookDTO), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetBookById(string id) + { + _logger.LogDebug("Get book by ID"); + var bookDto = (await DtoManager.GetBookById(id)); + if(bookDto == null) + { + _logger.LogInformation($"{id} not found"); + return NotFound(); + } + _logger.LogInformation($"{bookDto.Title} found"); + return Ok(bookDto); + } + + /// + /// Gets author by id + /// + /// id of the author to get + /// the author with the seeked id (or null) + /// + /// Sample requests: + /// + /// book/getAuthorById/OL1846639A + /// + /// + /// Returns the author with this id + /// no author found + [HttpGet("getAuthorById/{id?}")] + [ProducesResponseType(typeof(AuthorDTO), StatusCodes.Status200OK)] + [ProducesResponseType(StatusCodes.Status404NotFound)] + public async Task GetAuthorById(string id) + { + _logger.LogDebug("Get Author by ID"); + var authorDTO = (await DtoManager.GetAuthorById(id)); + if(authorDTO == null) + { + _logger.LogInformation($"{id} not found"); + return NotFound(); + } + _logger.LogInformation($"{authorDTO.Name} found"); + return Ok(authorDTO); + } + } +} + diff --git a/Sources/OpenLibraryWrapper/OpenLibraryWrapper.csproj b/Sources/OpenLibraryWrapper/OpenLibraryWrapper.csproj new file mode 100644 index 0000000..897f6c5 --- /dev/null +++ b/Sources/OpenLibraryWrapper/OpenLibraryWrapper.csproj @@ -0,0 +1,40 @@ + + + + net7.0 + enable + enable + + + + + + 4 + + + 4 + + + + + + + + + + + + + + + + + + + + + + Always + + + diff --git a/Sources/OpenLibraryWrapper/Program.cs b/Sources/OpenLibraryWrapper/Program.cs new file mode 100644 index 0000000..ce0df32 --- /dev/null +++ b/Sources/OpenLibraryWrapper/Program.cs @@ -0,0 +1,26 @@ +using System.Reflection; +using DtoAbstractLayer; +using LibraryDTO; +using Microsoft.OpenApi.Models; +using OpenLibraryClient; +using StubbedDTO; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddSingleton(); +builder.Services.AddControllers(); +// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle +builder.Services.AddEndpointsApiExplorer(); + +var app = builder.Build(); + +app.UseHttpsRedirection(); + +app.UseAuthorization(); + +app.MapControllers(); + +app.Run(); + diff --git a/Sources/OpenLibraryWrapper/Properties/launchSettings.json b/Sources/OpenLibraryWrapper/Properties/launchSettings.json new file mode 100644 index 0000000..576d3d7 --- /dev/null +++ b/Sources/OpenLibraryWrapper/Properties/launchSettings.json @@ -0,0 +1,41 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:34424", + "sslPort": 44344 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "http://localhost:5117", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true + }, + "https": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:7263;http://localhost:5117", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "dotnetRunMessages": true + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/Sources/OpenLibraryWrapper/appsettings.Development.json b/Sources/OpenLibraryWrapper/appsettings.Development.json new file mode 100644 index 0000000..ce16a2e --- /dev/null +++ b/Sources/OpenLibraryWrapper/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} + diff --git a/Sources/OpenLibraryWrapper/appsettings.json b/Sources/OpenLibraryWrapper/appsettings.json new file mode 100644 index 0000000..af0538f --- /dev/null +++ b/Sources/OpenLibraryWrapper/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} + diff --git a/Sources/OpenLibraryWrapper_UT/BookController_UT.cs b/Sources/OpenLibraryWrapper_UT/BookController_UT.cs new file mode 100644 index 0000000..f5bd29f --- /dev/null +++ b/Sources/OpenLibraryWrapper_UT/BookController_UT.cs @@ -0,0 +1,80 @@ +using DtoAbstractLayer; +using LibraryDTO; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.HttpResults; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Abstractions; +using OpenLibraryClient; +using OpenLibraryWrapper.Controllers; +using StubbedDTO; + +namespace OpenLibraryWrapper_UT; + +public class BookController_UT +{ + private readonly BookController controller; + private readonly IDtoManager dtoManager = new OpenLibClientAPI(); + + public BookController_UT() + { + var logger = new NullLogger(); + controller = new BookController(logger, dtoManager); + } + + [Theory] + [InlineData(true, "L'\u00c9veil du L\u00e9viathan", "9782330033118")] + [InlineData(false, null, "1782330033118")] + public async void TestGetBookByIsbn(bool expectedResult, string expectedTitle, string isbn) + { + var result = await controller.GetBookByIsbn(isbn); + Assert.Equal(expectedResult, result is OkObjectResult); + if(result is not OkObjectResult) + { + return; + } + var okResult = result as OkObjectResult; + var bookDto = okResult.Value as BookDTO; + Assert.Equal(expectedTitle, bookDto.Title); + } + + [Theory] + [InlineData(true, "L'\u00c9veil du L\u00e9viathan", "OL25910297M")] + [InlineData(false, null, "OL25910xxxM")] + public async void TestGetBookById(bool expectedResult, string expectedTitle, string id) + { + var result = await controller.GetBookById(id); + Assert.Equal(expectedResult, result is OkObjectResult); + if(result is not OkObjectResult) + { + return; + } + var okResult = result as OkObjectResult; + var bookDto = okResult.Value as BookDTO; + Assert.Equal(expectedTitle, bookDto.Title); + } + + [Fact] + public async void TestGetBooksByTitle() + { + var result = await controller.GetBooksByTitle("ne", 0, 5); + var okResult = result as OkObjectResult; + var booksTupple = (Tuple>)okResult.Value; + long nbBooks = booksTupple.Item1; + var books = booksTupple.Item2; + + Assert.True(nbBooks > 0); + } + + [Fact] + public async void TestGetBooksByAuthor() + { + var result = await controller.GetBooksByAuthor("al", 0, 5); + var okResult = result as OkObjectResult; + var booksTupple = (Tuple>)okResult.Value; + long nbBooks = booksTupple.Item1; + var books = booksTupple.Item2; + + Assert.Equal(5, books.Count()); + } +} diff --git a/Sources/OpenLibraryWrapper_UT/OpenLibraryWrapper_UT.csproj b/Sources/OpenLibraryWrapper_UT/OpenLibraryWrapper_UT.csproj new file mode 100644 index 0000000..ba2174d --- /dev/null +++ b/Sources/OpenLibraryWrapper_UT/OpenLibraryWrapper_UT.csproj @@ -0,0 +1,35 @@ + + + + net7.0 + enable + enable + + false + true + + + + 4 + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + + + diff --git a/Sources/OpenLibraryWrapper_UT/Usings.cs b/Sources/OpenLibraryWrapper_UT/Usings.cs new file mode 100644 index 0000000..9df1d42 --- /dev/null +++ b/Sources/OpenLibraryWrapper_UT/Usings.cs @@ -0,0 +1 @@ +global using Xunit; diff --git a/Sources/StubbedDTO/Stub.cs b/Sources/StubbedDTO/Stub.cs new file mode 100644 index 0000000..a23762c --- /dev/null +++ b/Sources/StubbedDTO/Stub.cs @@ -0,0 +1,200 @@ +using System.Data.SqlTypes; +using DtoAbstractLayer; +using JsonReader; +using LibraryDTO; +using static System.Reflection.Metadata.BlobBuilder; + +namespace StubbedDTO; + +public class Stub : IDtoManager +{ + public static List Authors { get; set; } = new List(); + + public static List Books { get; set; } = new List(); + + public static List Works { get; set; } = new List(); + + public static string BasePath { get; set; } = ""; + + static Stub() + { + foreach(var fileAuthor in new DirectoryInfo($"{BasePath}authors/").GetFiles()) + { + using(StreamReader reader = File.OpenText(fileAuthor.FullName)) + { + Authors.Add(AuthorJsonReader.ReadAuthor(reader.ReadToEnd())); + } + } + + foreach(var fileWork in new DirectoryInfo($"{BasePath}works/").GetFiles()) + { + var ratingsFile = $"{BasePath}ratings/{fileWork.Name.Insert((int)(fileWork.Name.Length - fileWork.Extension.Length), ".ratings")}"; + using(StreamReader reader = File.OpenText(fileWork.FullName)) + using(StreamReader readerRatings = File.OpenText(ratingsFile)) + { + var work = WorkJsonReader.ReadWork(reader.ReadToEnd(), readerRatings.ReadToEnd()); + foreach(var author in work.Authors.ToList()) + { + var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id); + work.Authors.Remove(author); + work.Authors.Add(newAuthor); + } + Works.Add(work); + } + } + + foreach(var fileBook in new DirectoryInfo($"{BasePath}books/").GetFiles()) + { + using(StreamReader reader = File.OpenText(fileBook.FullName)) + { + var book = BookJsonReader.ReadBook(reader.ReadToEnd()); + foreach(var author in book.Authors.ToList()) + { + var newAuthor = Authors.SingleOrDefault(a => a.Id == author.Id); + book.Authors.Remove(author); + book.Authors.Add(newAuthor); + } + foreach(var work in book.Works.ToList()) + { + var newWork = Works.SingleOrDefault(w => w.Id == work.Id); + book.Works.Remove(work); + book.Works.Add(newWork); + } + Books.Add(book); + } + } + + } + + public Task GetAuthorById(string id) + { + var author = Stub.Authors.SingleOrDefault(a => a.Id == id); + return Task.FromResult(author); + } + + private Task>> OrderAuthors(IEnumerable authors, int index, int count, string sort = "") + { + switch(sort) + { + case "name": + authors = authors.OrderBy(a => a.Name); + break; + case "name_reverse": + authors = authors.OrderByDescending(a => a.Name); + break; + } + return Task.FromResult(Tuple.Create((long)authors.Count(), authors.Skip(index*count).Take(count))); + } + + public async Task>> GetAuthors(int index, int count, string sort = "") + { + IEnumerable authors = Stub.Authors; + return await OrderAuthors(authors, index, count, sort); + } + + public async Task>> GetAuthorsByName(string name, int index, int count, string sort = "") + { + var authors = Stub.Authors.Where(a => a.Name.Contains(name, StringComparison.OrdinalIgnoreCase) + || a.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase))); + return await OrderAuthors(authors, index, count, sort); + } + + public Task GetBookById(string id) + { + var book = Stub.Books.SingleOrDefault(b => b.Id.Contains(id)); + return Task.FromResult(book); + } + + private Task>> OrderBooks(IEnumerable books, int index, int count, string sort = "") + { + switch(sort) + { + case "title": + books = books.OrderBy(b => b.Title); + break; + case "title_reverse": + books = books.OrderByDescending(b => b.Title); + break; + case "new": + books = books.OrderByDescending(b => b.PublishDate); + break; + case "old": + books = books.OrderBy(b => b.PublishDate); + break; + + } + return Task.FromResult(Tuple.Create((long)books.Count(), books.Skip(index*count).Take(count))); + } + + public async Task>> GetBooks(int index, int count, string sort = "") + { + var books = Stub.Books; + return await OrderBooks(books, index, count, sort); + } + + public Task GetBookByISBN(string isbn) + { + var book = Stub.Books.SingleOrDefault(b => b.ISBN13.Equals(isbn, StringComparison.OrdinalIgnoreCase)); + return Task.FromResult(book); + } + + public async Task>> GetBooksByTitle(string title, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => b.Title.Contains(title, StringComparison.OrdinalIgnoreCase) + || b.Series.Exists(s => s.Contains(title, StringComparison.OrdinalIgnoreCase))); + return await OrderBooks(books, index, count, sort); + } + + public async Task>> GetBooksByAuthorId(string authorId, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => b.Authors.Exists(a => a.Id == authorId) + || b.Works.Exists(w => w.Authors.Exists(a => a.Id == authorId))); + return await OrderBooks(books, index, count, sort); + } + + public async Task>> GetBooksByAuthor(string name, int index, int count, string sort = "") + { + var books = Stub.Books.Where(b => ContainsAuthorName(b, name)); + return await OrderBooks(books, index, count, sort); + } + + private bool ContainsAuthorName(BookDTO book, string name) + { + IEnumerable authors = new List(); + + if(book.Authors != null) + { + authors = authors.Union(book.Authors); + } + if(book.Works != null) + { + authors = authors.Union(book.Works.SelectMany(w => w.Authors)); + } + foreach(var author in authors) + { + if(author.Name.Contains(name, StringComparison.OrdinalIgnoreCase) + || author.AlternateNames.Exists(alt => alt.Contains(name, StringComparison.OrdinalIgnoreCase))) + { + return true; + } + } + return false; + } + + public Task>> GetWorks(int index, int count) + { + long nbWorks = Stub.Works.Count; + var works = Stub.Works.Skip(index*count).Take(count); + return Task.FromResult(Tuple.Create(nbWorks, works)); + } + + public Task GetNbAuthors() + => Task.FromResult((long)Stub.Authors.Count); + + public Task GetNbBooks() + => Task.FromResult((long)Stub.Books.Count); + + public Task GetNbWorks() + => Task.FromResult((long)Stub.Works.Count); +} + diff --git a/Sources/StubbedDTO/StubbedDTO.csproj b/Sources/StubbedDTO/StubbedDTO.csproj new file mode 100644 index 0000000..d57911e --- /dev/null +++ b/Sources/StubbedDTO/StubbedDTO.csproj @@ -0,0 +1,32 @@ + + + + net7.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + PreserveNewest + + + diff --git a/Sources/StubbedDTO/authors/OL1846639A.json b/Sources/StubbedDTO/authors/OL1846639A.json new file mode 100644 index 0000000..5bcb598 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL1846639A.json @@ -0,0 +1 @@ +{"name": "Michel Demuth", "personal_name": "Michel Demuth", "last_modified": {"type": "/type/datetime", "value": "2008-08-26 02:41:15.604911"}, "key": "/authors/OL1846639A", "type": {"key": "/type/author"}, "id": 6527877, "revision": 2} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL274606A.json b/Sources/StubbedDTO/authors/OL274606A.json new file mode 100644 index 0000000..6c8da79 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL274606A.json @@ -0,0 +1 @@ +{"personal_name": "Dick, Philip K.", "source_records": ["amazon:8445007327", "bwb:9780722129562", "amazon:0792776232", "ia:pacificpark0000dick", "amazon:2277213799", "amazon:2266163019", "bwb:9798599263227", "amazon:1433276712", "ia:ejonescreoilmond0000dick", "amazon:6051719164", "amazon:6254493632", "amazon:2277117749", "amazon:1987781619", "amazon:1433248239", "amazon:1480594407"], "alternate_names": ["Philip Kindred Dick", "Philip Dick", "Philip Kendred Dick", "Philip K Dick"], "bio": "Philip Kindred Dick was an American novelist, short story writer, and essayist whose published work during his lifetime was almost entirely in the science fiction genre. Dick explored sociological, political and metaphysical themes in novels dominated by monopolistic corporations, authoritarian governments, and altered states. In his later works, Dick's thematic focus strongly reflected his personal interest in metaphysics and theology. He often drew upon his own life experiences and addressed the nature of drug abuse, paranoia and schizophrenia, and transcendental experiences in novels such as A Scanner Darkly and VALIS.\r\n\r\nSource and more information: [Wikipedia (EN)](http://en.wikipedia.org/wiki/Philip_K._Dick)", "type": {"key": "/type/author"}, "death_date": "2 March 1982", "remote_ids": {"isni": "0000000121251093", "wikidata": "Q171091", "viaf": "27063583"}, "name": "Philip K. Dick", "links": [{"title": "Wikipedia link to Philip K Dick", "url": "http://en.wikipedia.org/wiki/Philip_K._Dick", "type": {"key": "/type/link"}}], "photos": [6295259], "birth_date": "16 December 1928", "key": "/authors/OL274606A", "latest_revision": 23, "revision": 23, "created": {"type": "/type/datetime", "value": "2008-04-01T03:28:50.625462"}, "last_modified": {"type": "/type/datetime", "value": "2022-11-29T21:21:41.951561"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL3113922A.json b/Sources/StubbedDTO/authors/OL3113922A.json new file mode 100644 index 0000000..56f0fbd --- /dev/null +++ b/Sources/StubbedDTO/authors/OL3113922A.json @@ -0,0 +1 @@ +{"name": "H\u00e9l\u00e8ne Collon", "last_modified": {"type": "/type/datetime", "value": "2008-04-30 08:14:56.482104"}, "key": "/authors/OL3113922A", "type": {"key": "/type/author"}, "id": 11970257, "revision": 1} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL3980331A.json b/Sources/StubbedDTO/authors/OL3980331A.json new file mode 100644 index 0000000..66382b5 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL3980331A.json @@ -0,0 +1 @@ +{"name": "Alain Damasio", "key": "/authors/OL3980331A", "type": {"key": "/type/author"}, "remote_ids": {"wikidata": "Q2829704"}, "birth_date": "1 August 1969", "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2008-04-30T20:50:18.033121"}, "last_modified": {"type": "/type/datetime", "value": "2022-12-19T19:05:32.693708"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL6982995A.json b/Sources/StubbedDTO/authors/OL6982995A.json new file mode 100644 index 0000000..271a70c --- /dev/null +++ b/Sources/StubbedDTO/authors/OL6982995A.json @@ -0,0 +1 @@ +{"personal_name": "James S. A. Corey", "remote_ids": {"isni": "0000000382626033", "viaf": "266413968", "wikidata": "Q6142591"}, "source_records": ["amazon:1478933771", "amazon:1528822218", "amazon:1456121650", "bwb:9780356510385", "amazon:0678452547", "bwb:9780356517773"], "alternate_names": ["Daniel Abraham", "Ty Franck", "James S.A. Corey", "James James S. A. Corey"], "type": {"key": "/type/author"}, "key": "/authors/OL6982995A", "entity_type": "org", "links": [{"title": "Source", "url": "http://www.danielabraham.com/james-s-a-corey/", "type": {"key": "/type/link"}}], "bio": {"type": "/type/text", "value": "James S.A. Corey is the pen name used by collaborators [Daniel Abraham](https://openlibrary.org/authors/OL1427729A/Daniel_Abraham) and [Ty Franck](https://openlibrary.org/authors/OL7523472A/Ty_Franck).\r\n\r\nThe first and last name are taken from Abraham's and Franck's middle names, respectively, and S.A. are the initials of Abraham's daughter."}, "photos": [11112303], "name": "James S. A. Corey", "latest_revision": 13, "revision": 13, "created": {"type": "/type/datetime", "value": "2011-10-20T08:06:05.906616"}, "last_modified": {"type": "/type/datetime", "value": "2023-05-18T18:14:26.659278"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL7475792A.json b/Sources/StubbedDTO/authors/OL7475792A.json new file mode 100644 index 0000000..5ff57b9 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL7475792A.json @@ -0,0 +1 @@ +{"key": "/authors/OL7475792A", "name": "Ada Palmer", "type": {"key": "/type/author"}, "latest_revision": 4, "revision": 4, "created": {"type": "/type/datetime", "value": "2019-03-11T19:38:25.579004"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T07:11:29.213401"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/authors/OL9956442A.json b/Sources/StubbedDTO/authors/OL9956442A.json new file mode 100644 index 0000000..9e515a7 --- /dev/null +++ b/Sources/StubbedDTO/authors/OL9956442A.json @@ -0,0 +1 @@ +{"type": {"key": "/type/author"}, "name": "Frank Herbert", "key": "/authors/OL9956442A", "source_records": ["amazon:2221252306"], "latest_revision": 1, "revision": 1, "created": {"type": "/type/datetime", "value": "2021-11-14T17:07:35.515652"}, "last_modified": {"type": "/type/datetime", "value": "2021-11-14T17:07:35.515652"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL25910297M.json b/Sources/StubbedDTO/books/OL25910297M.json new file mode 100644 index 0000000..249fb9e --- /dev/null +++ b/Sources/StubbedDTO/books/OL25910297M.json @@ -0,0 +1 @@ +{"publishers": ["Actes Sud"], "title": "L'\u00c9veil du L\u00e9viathan", "number_of_pages": 624, "isbn_13": ["9782330033118"], "covers": [7412481], "languages": [{"key": "/languages/fre"}], "publish_date": "4 juin 2014", "key": "/books/OL25910297M", "publish_places": ["France"], "works": [{"key": "/works/OL17334140W"}], "type": {"key": "/type/edition"}, "source_records": ["amazon:2330033117"], "latest_revision": 5, "revision": 5, "created": {"type": "/type/datetime", "value": "2016-04-22T11:47:01.838591"}, "last_modified": {"type": "/type/datetime", "value": "2023-02-02T01:19:11.921173"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL35698083M.json b/Sources/StubbedDTO/books/OL35698083M.json new file mode 100644 index 0000000..2310127 --- /dev/null +++ b/Sources/StubbedDTO/books/OL35698083M.json @@ -0,0 +1 @@ +{"works": [{"key": "/works/OL19635836W"}], "title": "La Volont\u00e9 de se battre", "publishers": ["Le B\u00e9lial'"], "publish_date": "2020", "key": "/books/OL35698083M", "type": {"key": "/type/edition"}, "identifiers": {}, "covers": [12392970], "isbn_13": ["9782843449758"], "classifications": {}, "languages": [{"key": "/languages/fre"}], "contributors": [{"name": "Michelle Charrier", "role": "Translator"}], "number_of_pages": 526, "series": ["Terra Ignota #3"], "physical_format": "paperback", "latest_revision": 3, "revision": 3, "created": {"type": "/type/datetime", "value": "2021-12-07T02:23:07.593997"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T02:24:57.135563"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL35699439M.json b/Sources/StubbedDTO/books/OL35699439M.json new file mode 100644 index 0000000..cf469d9 --- /dev/null +++ b/Sources/StubbedDTO/books/OL35699439M.json @@ -0,0 +1 @@ +{"type": {"key": "/type/edition"}, "title": "La Zone du Dehors", "authors": [{"key": "/authors/OL3980331A"}], "publish_date": "Feb 04, 2021", "source_records": ["amazon:2072927528"], "number_of_pages": 656, "publishers": ["FOLIO", "GALLIMARD"], "isbn_10": ["2072927528"], "isbn_13": ["9782072927522"], "physical_format": "pocket book", "full_title": "La Zone du Dehors", "covers": [12393645], "works": [{"key": "/works/OL19960903W"}], "key": "/books/OL35699439M", "latest_revision": 1, "revision": 1, "created": {"type": "/type/datetime", "value": "2021-12-07T22:26:13.534930"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T22:26:13.534930"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL38218739M.json b/Sources/StubbedDTO/books/OL38218739M.json new file mode 100644 index 0000000..942bbec --- /dev/null +++ b/Sources/StubbedDTO/books/OL38218739M.json @@ -0,0 +1 @@ +{"type": {"key": "/type/edition"}, "title": "Dune - tome 1", "authors": [{"key": "/authors/OL9956442A"}, {"key": "/authors/OL1846639A"}], "publish_date": "Nov 22, 2012", "source_records": ["amazon:2266233203"], "number_of_pages": 832, "publishers": ["POCKET", "Pocket"], "isbn_10": ["2266233203"], "isbn_13": ["9782266233200"], "physical_format": "pocket book", "notes": {"type": "/type/text", "value": "Source title: Dune - tome 1 (1)"}, "works": [{"key": "/works/OL27962193W"}], "key": "/books/OL38218739M", "latest_revision": 1, "revision": 1, "created": {"type": "/type/datetime", "value": "2022-05-30T17:18:00.228322"}, "last_modified": {"type": "/type/datetime", "value": "2022-05-30T17:18:00.228322"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/books/OL38586212M.json b/Sources/StubbedDTO/books/OL38586212M.json new file mode 100644 index 0000000..5be49c0 --- /dev/null +++ b/Sources/StubbedDTO/books/OL38586212M.json @@ -0,0 +1 @@ +{"type": {"key": "/type/edition"}, "title": "Total Recall et autres r\u00e9cits", "authors": [{"key": "/authors/OL274606A"}, {"key": "/authors/OL3113922A"}], "publish_date": "Jul 12, 2012", "source_records": ["amazon:2070448908"], "number_of_pages": 448, "publishers": ["FOLIO", "GALLIMARD"], "isbn_10": ["2070448908"], "isbn_13": ["9782070448906"], "physical_format": "pocket book", "works": [{"key": "/works/OL28185064W"}], "key": "/books/OL38586212M", "covers": [13858141], "latest_revision": 3, "revision": 3, "created": {"type": "/type/datetime", "value": "2022-07-10T01:29:29.296699"}, "last_modified": {"type": "/type/datetime", "value": "2023-04-07T22:44:13.567567"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL17334140W.ratings.json b/Sources/StubbedDTO/ratings/OL17334140W.ratings.json new file mode 100644 index 0000000..85e13a6 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL17334140W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL19635836W.ratings.json b/Sources/StubbedDTO/ratings/OL19635836W.ratings.json new file mode 100644 index 0000000..373d6c8 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19635836W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 4.8, "count": 5, "sortable": 3.216059213089321}, "counts": {"1": 0, "2": 0, "3": 0, "4": 1, "5": 4}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL19960903W.ratings.json b/Sources/StubbedDTO/ratings/OL19960903W.ratings.json new file mode 100644 index 0000000..4cbb213 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL19960903W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 4.0, "count": 1, "sortable": 2.3286737413641063}, "counts": {"1": 0, "2": 0, "3": 0, "4": 1, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL27962193W.ratings.json b/Sources/StubbedDTO/ratings/OL27962193W.ratings.json new file mode 100644 index 0000000..c2901fe --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL27962193W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": 3.0, "count": 1, "sortable": 2.19488243981746}, "counts": {"1": 0, "2": 0, "3": 1, "4": 0, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/ratings/OL28185064W.ratings.json b/Sources/StubbedDTO/ratings/OL28185064W.ratings.json new file mode 100644 index 0000000..85e13a6 --- /dev/null +++ b/Sources/StubbedDTO/ratings/OL28185064W.ratings.json @@ -0,0 +1 @@ +{"summary": {"average": null, "count": 0}, "counts": {"1": 0, "2": 0, "3": 0, "4": 0, "5": 0}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL17334140W.json b/Sources/StubbedDTO/works/OL17334140W.json new file mode 100644 index 0000000..637e78d --- /dev/null +++ b/Sources/StubbedDTO/works/OL17334140W.json @@ -0,0 +1 @@ +{"title": "L'\u00c9veil du L\u00e9viathan", "key": "/works/OL17334140W", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL6982995A"}}], "type": {"key": "/type/work"}, "covers": [7412481], "latest_revision": 3, "revision": 3, "created": {"type": "/type/datetime", "value": "2016-04-22T11:47:01.838591"}, "last_modified": {"type": "/type/datetime", "value": "2023-02-02T01:19:11.921173"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19635836W.json b/Sources/StubbedDTO/works/OL19635836W.json new file mode 100644 index 0000000..47d4eea --- /dev/null +++ b/Sources/StubbedDTO/works/OL19635836W.json @@ -0,0 +1 @@ +{"description": "\"The long years of near-utopia have come to an abrupt end. Peace and order are now figments of the past. Corruption, deception, and insurgency hum within the once steadfast leadership of the Hives, nations without fixed location. The heartbreaking truth is that for decades, even centuries, the leaders of the great Hives bought the world's stability with a trickle of secret murders, mathematically planned. So that no faction could ever dominate. So that the balance held. The Hives' fa\u00e7ade of solidity is the only hope they have for maintaining a semblance of order, for preventing the public from succumbing to the savagery and bloodlust of wars past. But as the great secret becomes more and more widely known, that fa\u00e7ade is slipping away. Just days earlier, the world was a pinnacle of human civilization. Now everyone--Hives and hiveless, Utopians and sensayers, emperors and the downtrodden, warriors and saints--scrambles to prepare for the seemingly inevitable war\"--", "covers": [8544084, 8619055, 10180814], "key": "/works/OL19635836W", "authors": [{"author": {"key": "/authors/OL7475792A"}, "type": {"key": "/type/author_role"}}], "title": "The Will to Battle", "subjects": ["Utopias", "Fiction", "Fiction, science fiction, general", "series:terra_ignota"], "type": {"key": "/type/work"}, "latest_revision": 7, "revision": 7, "created": {"type": "/type/datetime", "value": "2019-04-21T08:07:12.674468"}, "last_modified": {"type": "/type/datetime", "value": "2021-12-07T07:08:28.885088"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL19960903W.json b/Sources/StubbedDTO/works/OL19960903W.json new file mode 100644 index 0000000..4c399ab --- /dev/null +++ b/Sources/StubbedDTO/works/OL19960903W.json @@ -0,0 +1 @@ +{"title": "La zone du dehors", "key": "/works/OL19960903W", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL3980331A"}}], "type": {"key": "/type/work"}, "covers": [13472433], "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2019-07-17T23:01:16.580404"}, "last_modified": {"type": "/type/datetime", "value": "2023-03-15T21:59:10.897047"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL27962193W.json b/Sources/StubbedDTO/works/OL27962193W.json new file mode 100644 index 0000000..f373418 --- /dev/null +++ b/Sources/StubbedDTO/works/OL27962193W.json @@ -0,0 +1 @@ +{"type": {"key": "/type/work"}, "title": "Dune - tome 1", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL9956442A"}}, {"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL1846639A"}}], "key": "/works/OL27962193W", "covers": [13823878], "latest_revision": 2, "revision": 2, "created": {"type": "/type/datetime", "value": "2022-05-30T17:18:00.228322"}, "last_modified": {"type": "/type/datetime", "value": "2023-04-04T09:05:11.531979"}} \ No newline at end of file diff --git a/Sources/StubbedDTO/works/OL28185064W.json b/Sources/StubbedDTO/works/OL28185064W.json new file mode 100644 index 0000000..00f1ace --- /dev/null +++ b/Sources/StubbedDTO/works/OL28185064W.json @@ -0,0 +1 @@ +{"type": {"key": "/type/work"}, "title": "Total Recall et autres r\u00e9cits", "authors": [{"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL274606A"}}, {"type": {"key": "/type/author_role"}, "author": {"key": "/authors/OL3113922A"}}], "key": "/works/OL28185064W", "covers": [13858141], "latest_revision": 3, "revision": 3, "created": {"type": "/type/datetime", "value": "2022-07-10T01:29:29.296699"}, "last_modified": {"type": "/type/datetime", "value": "2023-04-07T22:44:13.567567"}} \ No newline at end of file diff --git a/screens/doxygen1.png b/screens/doxygen1.png new file mode 100644 index 0000000..df1a36f Binary files /dev/null and b/screens/doxygen1.png differ diff --git a/screens/doxygen2.png b/screens/doxygen2.png new file mode 100644 index 0000000..e6b0713 Binary files /dev/null and b/screens/doxygen2.png differ diff --git a/screens/swagger.png b/screens/swagger.png new file mode 100644 index 0000000..20c6fae Binary files /dev/null and b/screens/swagger.png differ