From 2e1f633f405a2e9ac6ca38bc851e09674672b41d Mon Sep 17 00:00:00 2001 From: Glax Date: Fri, 26 Apr 2024 00:05:48 +0200 Subject: [PATCH] Add Endpoint POST /v2/Manga/internalId/moveFolder #167 --- Tranga/Server/Server.cs | 1 + Tranga/Server/v2Manga.cs | 13 +++++++++++++ docs/API_Calls_v2.md | 25 +++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/Tranga/Server/Server.cs b/Tranga/Server/Server.cs index cde7bd9..cc8db46 100644 --- a/Tranga/Server/Server.cs +++ b/Tranga/Server/Server.cs @@ -30,6 +30,7 @@ public partial class Server : GlobalBase, IDisposable new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Chapters", GetV2MangaInternalIdChapters), new ("GET", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/Chapters/Latest", GetV2MangaInternalIdChaptersLatest), new ("POST", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/ignoreChaptersBelow", PostV2MangaInternalIdIgnoreChaptersBelow), + new ("POST", @"/v2/Manga/([-A-Za-z0-9]*={0,3})/moveFolder", PostV2MangaInternalIdMoveFolder), new ("GET", @"/v2/Jobs", GetV2Jobs), new ("GET", @"/v2/Jobs/Running", GetV2JobsRunning), new ("GET", @"/v2/Jobs/Waiting", GetV2JobsWaiting), diff --git a/Tranga/Server/v2Manga.cs b/Tranga/Server/v2Manga.cs index cee3dfa..947d039 100644 --- a/Tranga/Server/v2Manga.cs +++ b/Tranga/Server/v2Manga.cs @@ -92,4 +92,17 @@ public partial class Server }else return new ValueTuple(HttpStatusCode.InternalServerError, "Parameter 'startChapter' missing, or failed to parse."); } + + private ValueTuple PostV2MangaInternalIdMoveFolder(GroupCollection groups, Dictionary requestParameters) + { + + if(groups.Count < 1 || + !_parent.TryGetPublicationById(groups[1].Value, out Manga? manga) || + manga is null) + return new ValueTuple(HttpStatusCode.NotFound, $"Manga with ID '{groups[1].Value} could not be found.'"); + if(!requestParameters.TryGetValue("location", out string? newFolder)) + return new ValueTuple(HttpStatusCode.BadRequest, "Parameter 'location' missing."); + manga.Value.MovePublicationFolder(settings.downloadLocation, newFolder); + return new ValueTuple(HttpStatusCode.OK, null); + } } \ No newline at end of file diff --git a/docs/API_Calls_v2.md b/docs/API_Calls_v2.md index 867b3fa..e42a1f4 100644 --- a/docs/API_Calls_v2.md +++ b/docs/API_Calls_v2.md @@ -219,6 +219,31 @@ Returns the latest Chapter of the specified Manga. | 500 | Parsing Error | +### ![POST](https://img.shields.io/badge/POST-00f) `/v2/Manga//moveFolder` + +
+ Request + + `internalId` is returned in the response of + * [GET /v2/Manga](#-v2manga) + * [GET /v2/Connector/*ConnectorName*/GetManga](#-v2connectorconnectornamegetmanga) + * [GET /v2/Job/*jobId*](#-v2jobjobid) + + | Parameter | Value | + |-----------|-------------------------------------| + | location | New location (relative to root dir) | + +
+ +
+ Returns + + | StatusCode | Meaning | + |------------|--------------------------------------------| + | 400 | Parameter missing | + | 404 | Manga with `internalId` could not be found | +
+ ## Jobs [^top](#top) ### ![GET](https://img.shields.io/badge/GET-0f0) `/v2/Jobs`