Skip to content

Commit

Permalink
Move getQueues endpoint to get_queues
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Oct 30, 2020
1 parent aba6964 commit 20b0c37
Showing 1 changed file with 64 additions and 55 deletions.
119 changes: 64 additions & 55 deletions api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,72 +11,81 @@


class Item(Resource):
def get(self, queue: str, number: int) -> str:
"""Returns the JSON representation of the item requested.
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:
str: JSON representation of the item requested.
"""
return ECNQueue.Item(queue, number).toJson()
def get(self, queue: str, number: int) -> str:
"""Returns the JSON representation of the item requested.
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:
str: JSON representation of the item requested.
"""
return ECNQueue.Item(queue, number).toJson()

class Queue(Resource):
def get(self, queue: str) -> str:
"""Returns the JSON representation of the queue requested.
def get(self, queue: str) -> str:
"""Returns the JSON representation of the queue requested.
Args:
queue (str): The queue requested.
Args:
queue (str): The queue requested.
Returns:
str: JSON representation of the queue requested.
"""
queues_requested = queue.split("+")
Returns:
str: JSON representation of the queue requested.
"""
queues_requested = queue.split("+")

queues = []
for queue in queues_requested:
queues.append(ECNQueue.Queue(queue).toJson())
queues = []
for queue in queues_requested:
queues.append(ECNQueue.Queue(queue).toJson())

return queues
return queues

class QueueList(Resource):
def get(self) -> list:
"""Returns a list of queues and the number of items in the queue
Example:
[example]
Returns:
list: [description]
"""
return ECNQueue.getItemCount()

api.add_resource(QueueList, "/api/getQueues")
def get(self) -> list:
"""Returns a list of dictionaries with the number of items in each queue.
Example:
[
{
name: "me",
number_of_items: 42
},
{
name: "bidc",
number_of_items: 3
}
]
Returns:
list: Dictionaries with the number of items in each queue.
"""
return ECNQueue.getQueueCounts()

api.add_resource(QueueList, "/api/get_queues")
api.add_resource(Item, "/api/<string:queue>/<int:number>")
api.add_resource(Queue, "/api/<string:queue>")



if __name__ == "__main__":
app.run()
app.run()

0 comments on commit 20b0c37

Please sign in to comment.