import uuid
from datetime import datetime

from app.services.distribution.publishers.base import ContentPublisher, PublishResult


class MockPublisher(ContentPublisher):
    platform: str = ""

    def __init__(self, platform: str = "mock"):
        self.platform = platform

    async def publish(self, title: str, content: str, **kwargs) -> PublishResult:
        article_id = f"mock_{self.platform}_{uuid.uuid4().hex[:8]}"
        return PublishResult(
            success=True,
            platform=self.platform,
            article_id=article_id,
            article_url=f"https://mock.{self.platform}.com/articles/{article_id}",
            raw_response={
                "mock": True,
                "platform": self.platform,
                "title": title,
                "content_length": len(content),
                "published_at": datetime.now().isoformat(),
            },
        )

    async def verify_credentials(self) -> bool:
        return True

    async def get_article_status(self, article_id: str) -> dict:
        return {
            "article_id": article_id,
            "platform": self.platform,
            "status": "published",
            "mock": True,
        }
