File size: 851 Bytes
365f03f
12d44ef
b3e237c
 
e4dd8e6
b3e237c
 
e4dd8e6
 
b3e237c
 
 
e4dd8e6
b3e237c
 
 
 
3d9f63c
b3e237c
 
 
 
 
 
f6cb9db
3d9f63c
b3e237c
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
import json
from typing import Optional, List, Dict

class Attachment:
    def __init__(self, filename: str, data: str,attachment_len:int):
        self.filename = filename
        self.data = data
        self.attachment_len = attachment_len



class Message:
    def __init__(self, message_id: str, body: Optional[str], attachments: Optional[List[Attachment]], company: str , body_len:int):
        self.id = message_id
        self.body = body
        self.attachments = attachments
        self.company = company
        self.body_len = body_len

    def to_json(self):
        return {
            "id": self.id,
            "body": self.body,
            "attachments": [attachment.__dict__ for attachment in self.attachments] if self.attachments else None,
            "company": self.company,
            "body_len" : self.body_len,
        }