From 225db8bedabcfdf6db404d2634786904c5b25f9e Mon Sep 17 00:00:00 2001 From: Glax Date: Thu, 17 Oct 2024 21:03:37 +0200 Subject: [PATCH] Change return type of api request to get Connectors to get connector-list instead of dictionary --- Tranga/Server/v2Connector.cs | 2 +- Tranga/Tranga.cs | 4 ++-- docs/API_Calls_v2.md | 2 +- docs/Types.md | 26 ++++++++++++++++++-------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/Tranga/Server/v2Connector.cs b/Tranga/Server/v2Connector.cs index f84d039..58fd354 100644 --- a/Tranga/Server/v2Connector.cs +++ b/Tranga/Server/v2Connector.cs @@ -14,7 +14,7 @@ public partial class Server private ValueTuple GetV2ConnectorConnectorNameGetManga(GroupCollection groups, Dictionary requestParameters) { if(groups.Count < 1 || - !_parent.GetConnectors().Keys.Contains(groups[1].Value) || + !_parent.GetConnectors().Any(mangaConnector => mangaConnector.name == groups[1].Value)|| !_parent.TryGetConnector(groups[1].Value, out MangaConnector? connector) || connector is null) return new ValueTuple(HttpStatusCode.BadRequest, $"Connector '{groups[1].Value}' does not exist."); diff --git a/Tranga/Tranga.cs b/Tranga/Tranga.cs index 7c3271d..a463877 100644 --- a/Tranga/Tranga.cs +++ b/Tranga/Tranga.cs @@ -50,9 +50,9 @@ public partial class Tranga : GlobalBase return connector is not null; } - public Dictionary GetConnectors() + public List GetConnectors() { - return _connectors.ToDictionary(c => c.name, c => c.SupportedLanguages); + return _connectors.ToList(); } public Manga? GetPublicationById(string internalId) => GetCachedManga(internalId); diff --git a/docs/API_Calls_v2.md b/docs/API_Calls_v2.md index ee949ec..559acca 100644 --- a/docs/API_Calls_v2.md +++ b/docs/API_Calls_v2.md @@ -34,7 +34,7 @@ Returns available Manga Connectors (Scanlation sites)
Returns - Dictionary with Connector-Names and supported languages. + List of [Connectors](Types.md#Connector)
### ![GET](https://img.shields.io/badge/GET-0f0) `/v2/Connector//GetManga` diff --git a/docs/Types.md b/docs/Types.md index 9a7ae3d..293cf1d 100644 --- a/docs/Types.md +++ b/docs/Types.md @@ -1,41 +1,51 @@ -## Manga -```json +## Connector + +``` { + "name": string, + "SupportedLanguages": string[] +} +``` + +## Manga +``` +{ + } ``` ## Chapter -```json +``` { } ``` ## Job -```json +``` { } ``` ## ProgressToken -```json +``` { } ``` ## Settings -```json +``` { } ``` ## LibraryConnector -```json +``` { } ``` ## NotificationConnector -```json +``` { } ``` \ No newline at end of file