Coverage for src/kwai/modules/club/domain/contact.py: 100%
37 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines the contact entity."""
3from kwai.core.domain.entity import Entity
4from kwai.core.domain.value_objects.email_address import EmailAddress
5from kwai.core.domain.value_objects.identifier import IntIdentifier
6from kwai.core.domain.value_objects.traceable_time import TraceableTime
7from kwai.modules.club.domain.value_objects import Address
10ContactIdentifier = IntIdentifier
13class ContactEntity(Entity[ContactIdentifier]):
14 """A contact entity."""
16 def __init__(
17 self,
18 *,
19 id_: ContactIdentifier | None = None,
20 emails: list[EmailAddress] | None = None,
21 tel: str = "",
22 mobile: str = "",
23 address: Address,
24 remark: str = "",
25 traceable_time: TraceableTime | None = None,
26 ):
27 """Initialize the contact entity."""
28 super().__init__(id_ or ContactIdentifier())
29 self._emails = emails or []
30 self._tel = tel
31 self._mobile = mobile
32 self._address = address
33 self._remark = remark
34 self._traceable_time = traceable_time or TraceableTime()
36 @property
37 def emails(self) -> list[EmailAddress]:
38 """Return the emails of the contact.
40 Note: the returned list is a copy.
41 """
42 return self._emails.copy()
44 def add_email(self, email: EmailAddress) -> None:
45 """Add an email to the contact."""
46 self._emails.append(email)
48 def remove_email(self, email: EmailAddress) -> None:
49 """Remove the email from the contact."""
50 self._emails.remove(email)
52 @property
53 def tel(self) -> str:
54 """Return the tel."""
55 return self._tel
57 @property
58 def mobile(self) -> str:
59 """Return the mobile."""
60 return self._mobile
62 @property
63 def address(self) -> Address:
64 """Return the address."""
65 return self._address
67 @property
68 def remark(self) -> str:
69 """Return the remark."""
70 return self._remark
72 @property
73 def traceable_time(self) -> TraceableTime:
74 """Return the traceable_time."""
75 return self._traceable_time