Omkar008's picture
Update models/models.py
6a48853 verified
raw
history blame
No virus
868 Bytes
import json
from typing import Optional, List, Dict
class Attachment:
def __init__(self, attachment_len:int,filename: str, data: str):
self.attachment_len = attachment_len
self.filename = filename
self.data = data
class Message:
def __init__(self, message_id: str, body_len:int, body: Optional[str], attachments: Optional[List[Attachment]], company: str ):
self.id = message_id
self.body_len = body_len
self.body = body
self.attachments = attachments
self.company = company
def to_json(self):
return {
"id": self.id,
"body_len" : self.body_len,
"body": self.body,
"attachments": [attachment.__dict__ for attachment in self.attachments] if self.attachments else None,
"company": self.company
}