-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from flask_restful import Resource | ||
from flask_jwt_extended import jwt_required | ||
from webqueue2api.parser import Item | ||
from webqueue2api.parser.errors import ItemDoesNotExistError | ||
|
||
class ItemResource(Resource): | ||
# @jwt_required | ||
def get(self, queue: str, number: int) -> tuple: | ||
"""Returns the JSON representation of the item requested. | ||
Return Codes: | ||
200 (OK): On success. | ||
Example: | ||
/api/ce/100 returns: | ||
{ | ||
"lastUpdated": "07-23-20 10:11 PM", | ||
"headers": [...], | ||
"content": [...], | ||
"isLocked": "ce 100 is locked by knewell using qvi", | ||
"userEmail": "campb303@purdue.edu", | ||
"userName": "Justin Campbell", | ||
"userAlias": "campb303", | ||
"assignedTo": "campb303", | ||
"subject": "Beepboop", | ||
"status": "Dont Delete", | ||
"priority": "", | ||
"deparment": "", | ||
"building": "", | ||
"dateReceived": "Tue, 23 Jun 2020 13:25:51 -0400" | ||
} | ||
Args: | ||
queue (str): The queue of the item requested. | ||
item (int): The number of the item requested. | ||
Returns: | ||
tuple: Item as JSON and HTTP response code. | ||
""" | ||
try: | ||
return (Item(queue, number).toJson(), 200) | ||
except ItemDoesNotExistError: | ||
return ({"message": f"Item {queue}{number} not found."}, 404) |