Skip to content

Commit

Permalink
Implement toJson() in Item class
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Campbell committed Jul 27, 2020
1 parent 326fb2d commit d05adec
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/ECNQueue.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#------------------------------------------------------------------------------#
import os, time, email, re
from typing import Union
import json



Expand Down Expand Up @@ -40,6 +41,19 @@ def __init__(self, queue: str, number: int) -> None:
self.subject = self.__getMostRecentHeaderByType("Subject")["content"]
self.status = self.__getMostRecentHeaderByType("Status")["content"]

self.jsonData = {
"lastUpdated": self.lastUpdated,
"headers": self.headers,
"content": self.content,
"isLocked": self.isLocked,
"userEmail": self.userEmail,
"userName": self.userName,
"userAlias": self.userName,
"assignedTo": self.assignedTo,
"subject": self.subject,
"status": self.status
}

def __getLastUpdated(self) -> float:
"""Returns last modified time of item reported by the filesystem in mm-dd-yy hh:mm am/pm format.
Expand Down Expand Up @@ -246,6 +260,14 @@ def __getAssignedTo(self) -> str:
assignedTo = assignedToHeader["content"]
return assignedTo

def toJson(self) -> dict:
"""Returns a JSON safe representation of the item.
Returns:
dict: JSON safe representation of the item.
"""
return json.dumps(self.jsonData)

def __repr__(self) -> str:
return self.queue + str(self.number)

Expand Down

0 comments on commit d05adec

Please sign in to comment.