diff --git a/Tranga/Server/Server.cs b/Tranga/Server/Server.cs index bb3d6ea..d2a8640 100644 --- a/Tranga/Server/Server.cs +++ b/Tranga/Server/Server.cs @@ -24,6 +24,7 @@ public partial class Server : GlobalBase, IDisposable new ("GET", @"/v2/Connector/Types", GetV2ConnectorTypes), new ("GET", @"/v2/Connector/([a-zA-Z]+)/GetManga", GetV2ConnectorConnectorNameGetManga), new ("GET", @"/v2/Mangas", GetV2Mangas), + new ("GET", @"/v2/Manga", GetV2Manga), new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", GetV2MangaInternalId), new ("DELETE", @"/v2/Manga/([-A-Za-z0-9]*={0,3})", DeleteV2MangaInternalId), new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Cover", GetV2MangaInternalIdCover), diff --git a/Tranga/Server/v2Manga.cs b/Tranga/Server/v2Manga.cs index 9717e94..f983ec0 100644 --- a/Tranga/Server/v2Manga.cs +++ b/Tranga/Server/v2Manga.cs @@ -11,6 +11,22 @@ public partial class Server return new ValueTuple(HttpStatusCode.OK, GetAllCachedManga().Select(m => m.internalId)); } + private ValueTuple GetV2Manga(GroupCollection groups, Dictionary requestParameters) + { + if(!requestParameters.TryGetValue("mangaIds", out string? mangaIdListStr)) + return new ValueTuple(HttpStatusCode.BadRequest, "Missing parameter 'mangaIds'."); + string[] mangaIdList = mangaIdListStr.Split(','); + List ret = new(); + foreach (string mangaId in mangaIdList) + { + if(!_parent.TryGetPublicationById(mangaId, out Manga? manga) || manga is null) + return new ValueTuple(HttpStatusCode.NotFound, $"Manga with id '{mangaId}' not found."); + ret.Add(manga.Value); + } + + return new ValueTuple(HttpStatusCode.OK, ret); + } + private ValueTuple GetV2MangaInternalId(GroupCollection groups, Dictionary requestParameters) { if(groups.Count < 1 || diff --git a/docs/API_Calls_v2.md b/docs/API_Calls_v2.md index 6773089..f928ca6 100644 --- a/docs/API_Calls_v2.md +++ b/docs/API_Calls_v2.md @@ -100,6 +100,34 @@ Returns the specified Manga. | 404 | Manga with `internalId` could not be found | +### ![GET](https://img.shields.io/badge/GET-0f0) `/v2/Manga/` + +Returns the list of Mangas requested. + +
+ Request + + | Parameter | Value | + |-----------|--------------------------------------| + | mangaIds | Comma-Seperated list of `internalId` | + + `internalId` is returned in the response of + * [GET /v2/Manga](#-v2manga) + * [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga) + * [GET /v2/Job/*jobId*](#-v2jobjobid) +
+ +
+ Returns + + List of [Manga](Types.md#manga) + + | StatusCode | Meaning | + |------------|--------------------------------------------| + | 400 | Missing Parameter | + | 404 | Manga with `internalId` could not be found | +
+ ### ![DELETE](https://img.shields.io/badge/DELETE-f00) `/v2/Manga/` Deletes all associated Jobs for the specified Manga @@ -115,10 +143,12 @@ Deletes all associated Jobs for the specified Manga
Returns + + [Manga](Types.md#manga) | StatusCode | Meaning | |------------|--------------------------------------------| - | 200 | Jobs were deleted | + | 200 | Manga was deleted | | 404 | Manga with `internalId` could not be found |