From e00ae9e34486cdde95593ee28a474aac9714ff4b Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 18 May 2024 19:02:18 +0200 Subject: [PATCH] bruh --- grzegorz_clients/api.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/grzegorz_clients/api.py b/grzegorz_clients/api.py index a926ce5..9e8fb7a 100644 --- a/grzegorz_clients/api.py +++ b/grzegorz_clients/api.py @@ -16,7 +16,8 @@ def parse_message( url: str, status: str, function_name: str, - json_text: str + json_text: str, + is_get: bool, ) -> dict[str, any]: prefix = f"[{function_name}] {method} /{url} -> {status}:" try: @@ -33,8 +34,8 @@ def parse_message( if data["error"] != False: raise APIError(f"{prefix} Got error {str(data['error'])}, got:\n{json_text}") - if "success" not in data: - raise APIError(f"{prefix} Missing json data 'error', got:\n{json_text}") + if not is_get and "success" not in data: + raise APIError(f"{prefix} Missing json data 'success', got:\n{json_text}") return data @@ -52,6 +53,7 @@ def request_delete(func): response.status_code, func.__name__, response.text, + is_get = False, ) return data["success"] return new_func @@ -68,6 +70,7 @@ def request_post(func): response.status_code, func.__name__, response.text, + is_get = False, ) return data["success"] return new_func @@ -84,6 +87,7 @@ def request_get(func): response.status_code, func.__name__, response.text, + is_get = True, ) if "value" not in data: