@@ -262,6 +262,9 @@ class User(TastytradeJsonDataclass):
262262 nickname : Optional [str ] = None
263263
264264
265+ _fmt = "%Y-%m-%d %H:%M:%S%z"
266+
267+
265268class Session :
266269 """
267270 Contains a local user login which can then be used to interact with the
@@ -475,6 +478,8 @@ def serialize(self) -> str:
475478 del attrs ["async_client" ]
476479 del attrs ["sync_client" ]
477480 attrs ["user" ] = attrs ["user" ].model_dump ()
481+ attrs ["session_expiration" ] = self .session_expiration .strftime (_fmt )
482+ attrs ["streamer_expiration" ] = self .streamer_expiration .strftime (_fmt )
478483 return json .dumps (attrs )
479484
480485 @classmethod
@@ -492,6 +497,12 @@ def deserialize(cls, serialized: str) -> Self:
492497 "Content-Type" : "application/json" ,
493498 "Authorization" : self .session_token ,
494499 }
500+ self .session_expiration = datetime .strptime (
501+ deserialized ["session_expiration" ], _fmt
502+ )
503+ self .streamer_expiration = datetime .strptime (
504+ deserialized ["streamer_expiration" ], _fmt
505+ )
495506 self .sync_client = Client (base_url = base_url , headers = headers , proxy = self .proxy )
496507 self .async_client = AsyncClient (
497508 base_url = base_url , headers = headers , proxy = self .proxy
0 commit comments