2024-04-23 11:10:17 +03:00
|
|
|
from api.application.abstractions.transaction import TransactionContextManager
|
2024-04-01 01:12:01 +03:00
|
|
|
from api.application.contracts.user import GetUserByEmailRequest, UserResponse
|
|
|
|
from api.domain.user.repository import UserRepository
|
|
|
|
|
|
|
|
|
|
|
|
class GetUserByEmail:
|
2024-04-23 12:08:56 +03:00
|
|
|
def __init__(self, transaction: TransactionContextManager, user_repository: UserRepository) -> None:
|
2024-04-23 11:10:17 +03:00
|
|
|
self.transaction = transaction
|
2024-04-01 01:12:01 +03:00
|
|
|
self.user_repository = user_repository
|
|
|
|
|
|
|
|
async def execute(self, request: GetUserByEmailRequest) -> UserResponse | None:
|
2024-04-23 11:10:17 +03:00
|
|
|
async with self.transaction:
|
|
|
|
user = await self.user_repository.get_user(filter={"email": request.email})
|
|
|
|
if user:
|
|
|
|
return None
|
2024-04-01 01:12:01 +03:00
|
|
|
return None
|