From e9269170dcbf2db3804e851fc3ccafd8e3ce27c7 Mon Sep 17 00:00:00 2001 From: alemidev Date: Mon, 13 Dec 2021 13:36:52 +0100 Subject: [PATCH] added equals and str to token obj --- aiocraft/mc/token.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/aiocraft/mc/token.py b/aiocraft/mc/token.py index e860323..f1a45da 100644 --- a/aiocraft/mc/token.py +++ b/aiocraft/mc/token.py @@ -42,6 +42,22 @@ class Token: CONTENT_TYPE = "application/json" HEADERS = {"content-type": CONTENT_TYPE} + def __equals__(self, other) -> bool: + if not isinstance(other, self.__class__): + return False + if self.accessToken == other.accessToken \ + and self.clientToken == other.clientToken \ + and self.selectedProfile == other.selectedProfile: + # username doesn't matter, it can be included or not and we can fetch it at later time + return True + return False + + def __repr__(self) -> str: + return json.dumps(self.as_dict()) + + def __str__(self) -> str: + return repr(self) + def as_dict(self): return { "username":self.username,