11import time
22import random
3+ from datetime import datetime
34from dataclasses import dataclass
45
56import requests
@@ -80,6 +81,10 @@ class MessageInfo:
8081 date_str : str
8182 _mail : 'OneSecMail'
8283
84+ @property
85+ def date (self ) -> datetime :
86+ return datetime .fromisoformat (self .date_str )
87+
8388 @property
8489 def message (self ) -> 'OneSecMail.Message' :
8590 return self ._mail .get_message (self .id )
@@ -99,13 +104,21 @@ class Message:
99104 id : int
100105 from_addr : str
101106 subject : str
102- date : str
107+ date_str : str
103108 body : str
104109 test_body : str
105110 html_body : str
106111 _mail : 'OneSecMail'
107112 _attachments : list [dict [str , any ]]
108113
114+ @property
115+ def date (self ) -> datetime :
116+ return datetime .fromisoformat (self .date_str )
117+
118+ @property
119+ def attachments (self ) -> list ['OneSecMail.Attachment' ]:
120+ return [OneSecMail .Attachment .from_dict (self ._mail , self .id , attachment ) for attachment in self ._attachments ]
121+
109122 @classmethod
110123 def from_dict (cls , mail : 'OneSecMail' , msg : dict [str , any ]) -> 'OneSecMail.Message' :
111124 return cls (
@@ -114,16 +127,12 @@ def from_dict(cls, mail: 'OneSecMail', msg: dict[str, any]) -> 'OneSecMail.Messa
114127 id = msg ['id' ],
115128 from_addr = msg ['from' ],
116129 subject = msg ['subject' ],
117- date = msg ['date' ],
130+ date_str = msg ['date' ],
118131 body = msg ['textBody' ],
119132 test_body = msg ['textBody' ],
120133 html_body = msg ['htmlBody' ],
121134 )
122135
123- @property
124- def attachments (self ) -> list ['OneSecMail.Attachment' ]:
125- return [OneSecMail .Attachment .from_dict (self ._mail , self .id , attachment ) for attachment in self ._attachments ]
126-
127136 @dataclass
128137 class Attachment :
129138 filename : str
0 commit comments