"""
Base Adapter
Phase 6: Site Integration & Multi-Destination Publishing

Abstract base class for publishing adapters.
"""
from abc import ABC, abstractmethod
from typing import Dict, Any, Optional


class BaseAdapter(ABC):
    """
    Abstract base class for publishing adapters.
    All platform-specific adapters must inherit from this.
    """
    
    @abstractmethod
    def publish(
        self,
        content: Any,
        destination_config: Dict[str, Any]
    ) -> Dict[str, Any]:
        """
        Publish content to destination.
        
        Args:
            content: Content or SiteBlueprint to publish
            destination_config: Destination-specific configuration
        
        Returns:
            dict: {
                'success': bool,
                'external_id': str,  # External platform ID
                'url': str,  # Published content URL
                'published_at': datetime,
                'metadata': dict
            }
        """
        pass
    
    @abstractmethod
    def test_connection(
        self,
        config: Dict[str, Any]
    ) -> Dict[str, Any]:
        """
        Test connection to destination.
        
        Args:
            config: Destination configuration
        
        Returns:
            dict: {
                'success': bool,
                'message': str,
                'details': dict
            }
        """
        pass
    
    @abstractmethod
    def get_status(
        self,
        published_id: str,
        config: Dict[str, Any]
    ) -> Dict[str, Any]:
        """
        Get publishing status for published content.
        
        Args:
            published_id: External platform ID
            config: Destination configuration
        
        Returns:
            dict: {
                'status': str,  # 'published', 'draft', 'deleted', etc.
                'url': str,
                'updated_at': datetime,
                'metadata': dict
            }
        """
        pass
    
    def validate_config(
        self,
        config: Dict[str, Any]
    ) -> tuple:
        """
        Validate destination configuration.
        
        Args:
            config: Destination configuration
        
        Returns:
            tuple: (is_valid, error_message)
        """
        # Default implementation - can be overridden
        return True, None

