from uuid import UUID

from pydantic import BaseModel

from huesoporro.infra.repos import ChatbotRepo
from huesoporro.models import Chatbot


class CreateChatbotSvc(BaseModel):
    repo: ChatbotRepo

    async def run(self, chatbot: Chatbot):
        return await self.repo.create(chatbot)


class GetChatbotByUserIdSvc(BaseModel):
    repo: ChatbotRepo

    async def run(self, user_id: UUID) -> Chatbot | None:
        return await self.repo.get_by_user_id(user_id=user_id)


class UpdateChatbotSvc(BaseModel):
    repo: ChatbotRepo

    async def run(self, chatbot: Chatbot):
        return await self.repo.update(obj=chatbot)
