| 33 | |
| 34 | |
| 35 | class ChatAuthentication: |
| 36 | def __init__(self, auth_type: str | None, **kwargs): |
| 37 | self.auth_type = auth_type |
| 38 | for k, v in kwargs.items(): |
| 39 | self.__setattr__(k, v) |
| 40 | |
| 41 | def to_dict(self): |
| 42 | return self.__dict__ |
| 43 | |
| 44 | def to_string(self): |
| 45 | value = json.dumps(self.to_dict()) |
| 46 | authentication = encrypt(value) |
| 47 | cache_key = hashlib.sha256(authentication.encode()).hexdigest() |
| 48 | authentication_cache.set(cache_key, value, version=Cache_Version.CHAT.get_version(), timeout=60 * 60 * 2) |
| 49 | return authentication |
| 50 | |
| 51 | @staticmethod |
| 52 | def new_instance(authentication: str): |
| 53 | auth = json.loads(_decrypt(authentication)) |
| 54 | return ChatAuthentication(**auth) |
| 55 | |
| 56 | |
| 57 | class ChatUserToken: |
no outgoing calls
no test coverage detected