mirror of
				https://github.com/dancojocaru2000/foxbank.git
				synced 2025-10-31 00:26:31 +02:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			No EOL
		
	
	
		
			566 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			No EOL
		
	
	
		
			566 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| from dataclasses import dataclass
 | |
| 
 | |
| @dataclass
 | |
| class User:
 | |
|     id: int
 | |
|     username: str
 | |
|     email: str
 | |
|     otp: str
 | |
|     fullname: str
 | |
| 
 | |
|     def to_json(self, include_otp=False, include_id=False):
 | |
|         result = {
 | |
|             'username': self.username,
 | |
|             'email': self.email,
 | |
|             'fullname': self.fullname,
 | |
|         }
 | |
|         if include_id:
 | |
|             result['id'] = self.id
 | |
|         if include_otp:
 | |
|             result['otp'] = self.otp
 | |
|         return result
 | |
| 
 | |
|     @classmethod
 | |
|     def from_query(cls, query_result):
 | |
|         return cls(*query_result) |