service_man/api/application/usecase/user/get_user_by_email.py

17 lines
710 B
Python
Raw Permalink Normal View History

from api.application.abstractions.transaction import TransactionContextManager
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:
self.transaction = transaction
self.user_repository = user_repository
async def execute(self, request: GetUserByEmailRequest) -> UserResponse | None:
async with self.transaction:
user = await self.user_repository.get_user(filter={"email": request.email})
if user:
return None
return None