Last active
June 12, 2021 15:27
-
-
Save cassioeskelsen/1e80ac66eb2b0cc2c3b72517cb623e54 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @dataclass(eq=True) | |
| class Customer: | |
| name: str | |
| address: Address | |
| document: str | |
| insert_date: datetime = field(default_factory=datetime.datetime.now) | |
| Id: str = None | |
| def __hash__(self) -> int: | |
| return hash(self.Id) | |
| def get_customer(key, value): | |
| if not value: | |
| return None | |
| elif key == "state": | |
| return State(**value) | |
| elif key == "address" and not isinstance(value, str): | |
| return Address(**value) | |
| elif key in ['insert_date']: | |
| return dateutil.parser.isoparse(value) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment