from pydantic import BaseModel

from huesoporro.infra.repos import QuoteRepo
from huesoporro.models import Quote


class GetRandomQuoteSvc(BaseModel):
    repo: QuoteRepo

    async def run(self, channel_name: str) -> Quote | None:
        return await self.repo.get_random(channel_name=channel_name)


class CreateQuoteSvc(BaseModel):
    repo: QuoteRepo

    async def run(self, quote: Quote) -> Quote:
        return await self.repo.create(obj=quote)
