Skip to content

Commit

Permalink
Create ItemResource resource
Browse files Browse the repository at this point in the history
  • Loading branch information
campb303 committed Jun 16, 2021
1 parent afecc47 commit 9e4c10d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/webqueue2api/api/resources/item.py
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)

0 comments on commit 9e4c10d

Please sign in to comment.