2
0

Add Endpoint GET /v2/Manga to request multiple Manga from internalIds #167

This commit is contained in:
Glax 2024-04-26 00:22:17 +02:00
parent 49a9b7ccb0
commit 7f95ab9439
3 changed files with 48 additions and 1 deletions

View File

@ -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),

View File

@ -11,6 +11,22 @@ public partial class Server
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, GetAllCachedManga().Select(m => m.internalId));
}
private ValueTuple<HttpStatusCode, object?> GetV2Manga(GroupCollection groups, Dictionary<string, string> requestParameters)
{
if(!requestParameters.TryGetValue("mangaIds", out string? mangaIdListStr))
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.BadRequest, "Missing parameter 'mangaIds'.");
string[] mangaIdList = mangaIdListStr.Split(',');
List<Manga> ret = new();
foreach (string mangaId in mangaIdList)
{
if(!_parent.TryGetPublicationById(mangaId, out Manga? manga) || manga is null)
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, $"Manga with id '{mangaId}' not found.");
ret.Add(manga.Value);
}
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, ret);
}
private ValueTuple<HttpStatusCode, object?> GetV2MangaInternalId(GroupCollection groups, Dictionary<string, string> requestParameters)
{
if(groups.Count < 1 ||

View File

@ -100,6 +100,34 @@ Returns the specified Manga.
| 404 | Manga with `internalId` could not be found |
</details>
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Manga/`
Returns the list of Mangas requested.
<details>
<summary>Request</summary>
| 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)
</details>
<details>
<summary>Returns</summary>
List of [Manga](Types.md#manga)
| StatusCode | Meaning |
|------------|--------------------------------------------|
| 400 | Missing Parameter |
| 404 | Manga with `internalId` could not be found |
</details>
### <sub>![DELETE](https://img.shields.io/badge/DELETE-f00)</sub> `/v2/Manga/<internalId>`
Deletes all associated Jobs for the specified Manga
@ -116,9 +144,11 @@ Deletes all associated Jobs for the specified Manga
<details>
<summary>Returns</summary>
[Manga](Types.md#manga)
| StatusCode | Meaning |
|------------|--------------------------------------------|
| 200 | Jobs were deleted |
| 200 | Manga was deleted |
| 404 | Manga with `internalId` could not be found |
</details>