Omkar008's picture
Update models/models.py
57f6c59 verified
raw
history blame
No virus
1.28 kB
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:
#structured_data:Optional[List] add this in the below __init__
def __init__(self, message_id: str, body_len:int, body: Optional[str], attachments: Optional[List[Attachment]], company: str , high_level_company_type:str,structured_data:Optional[List]):
self.id = message_id
self.body_len = body_len
self.body = body
self.attachments = attachments
self.company = company
self.high_level_company_type = high_level_company_type
self.structured_data = structured_data
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,
"high_level_company_type":self.high_level_company_type,
"structured_data": self.structured_data if self.structured_data else None
}