Coverage for kwai/modules/identity/get_user_invitation.py: 100%
13 statements
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
« prev ^ index » next coverage.py v7.3.0, created at 2023-09-05 17:55 +0000
1"""Implement the use case: get a user invitation."""
2from dataclasses import dataclass
4from kwai.core.domain.value_objects.unique_id import UniqueId
5from kwai.modules.identity.user_invitations.user_invitation import UserInvitationEntity
6from kwai.modules.identity.user_invitations.user_invitation_repository import (
7 UserInvitationRepository,
8)
11@dataclass(kw_only=True, frozen=True, slots=True)
12class GetUserInvitationCommand:
13 """Input for the use case.
15 [GetUserInvitation][kwai.modules.identity.get_user_invitation.GetUserInvitation]
17 Attributes:
18 uuid: The unique id of the user invitation.
19 """
21 uuid: str
24class GetUserInvitation:
25 """Implements the use case 'get a user invitation'."""
27 def __init__(self, user_invitation_repo: UserInvitationRepository):
28 """Initialize the use case.
30 Args:
31 user_invitation_repo: A repository for getting the user invitation.
32 """
33 self._user_invitation_repo = user_invitation_repo
35 async def execute(self, command: GetUserInvitationCommand) -> UserInvitationEntity:
36 """Execute the use case.
38 Args:
39 command: The input for this use case.
41 Returns:
42 A user invitation entity
44 Raises:
45 UserInvitationNotFoundException: Raised when then invitation is not found.
46 """
47 entity = await self._user_invitation_repo.get_invitation_by_uuid(
48 UniqueId.create_from_string(command.uuid)
49 )
50 return entity