Spaces:
Sleeping
Sleeping
File size: 1,279 Bytes
365f03f 12d44ef b3e237c 6a48853 b3e237c 6a48853 e4dd8e6 b3e237c a3f7190 b3e237c 6a48853 b3e237c a3f7190 6a48853 b3e237c 6a48853 b3e237c a3f7190 b3e237c a3f7190 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
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
}
|