| 55 | |
| 56 | |
| 57 | class ChatUserToken: |
| 58 | def __init__(self, application_id, user_id, access_token, _type, chat_user_type, chat_user_id, |
| 59 | authentication: ChatAuthentication): |
| 60 | self.application_id = application_id |
| 61 | self.user_id = user_id |
| 62 | self.access_token = access_token |
| 63 | self.type = _type |
| 64 | self.chat_user_type = chat_user_type |
| 65 | self.chat_user_id = chat_user_id |
| 66 | self.authentication = authentication |
| 67 | |
| 68 | def to_dict(self): |
| 69 | return { |
| 70 | 'application_id': str(self.application_id), |
| 71 | 'user_id': str(self.user_id), |
| 72 | 'access_token': self.access_token, |
| 73 | 'type': str(self.type.value), |
| 74 | 'chat_user_type': str(self.chat_user_type), |
| 75 | 'chat_user_id': str(self.chat_user_id), |
| 76 | 'authentication': self.authentication.to_string() |
| 77 | } |
| 78 | |
| 79 | def to_token(self): |
| 80 | return signing.dumps(self.to_dict()) |
| 81 | |
| 82 | @staticmethod |
| 83 | def new_instance(token_dict): |
| 84 | return ChatUserToken(token_dict.get('application_id'), token_dict.get('user_id'), |
| 85 | token_dict.get('access_token'), token_dict.get('type'), token_dict.get('chat_user_type'), |
| 86 | token_dict.get('chat_user_id'), |
| 87 | ChatAuthentication.new_instance(token_dict.get('authentication'))) |
no outgoing calls
no test coverage detected