From b75f3d7275cd9207efe8885f3daaf61caf288843 Mon Sep 17 00:00:00 2001 From: Justin Campbell Date: Tue, 10 Nov 2020 15:57:37 -0500 Subject: [PATCH] Make Item resource return tuple w/ quueue JSON and HTTP return code plus update docs --- api/api.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/api/api.py b/api/api.py index b29b4f6..8c6a657 100644 --- a/api/api.py +++ b/api/api.py @@ -52,6 +52,7 @@ def post(self) -> tuple: 200 (OK): On success. 401 (Unauthroized): When username or password are incorrect. 422 (Unprocessable Entitiy): When the username or password can't be parsed. + 500 (Internal Server Error): On API error. Example: curl -X POST @@ -100,9 +101,13 @@ def post(self): class Item(Resource): @jwt_required - def get(self, queue: str, number: int) -> str: + def get(self, queue: str, number: int) -> tuple: """Returns the JSON representation of the item requested. + Return Codes: + 200 (OK): On success. + 500 (Internal Server Error): On API error. + Example: /api/ce/100 returns: { @@ -127,9 +132,9 @@ def get(self, queue: str, number: int) -> str: item (int): The number of the item requested. Returns: - str: JSON representation of the item requested. + tuple: Response containing queue as JSON and HTTP response code. """ - return ECNQueue.Item(queue, number).toJson() + return (ECNQueue.Item(queue, number).toJson(), 200) class Queue(Resource): @jwt_required