package com.social.media.domain.shared.enums;

/**
 * Enumeration of supported social media platforms.
 * 
 * This enum defines all social media platforms that the system can integrate with.
 * Each platform has its own unique characteristics, API endpoints, and capabilities.
 * 
 * @author Social Media Manager Team
 * @version 2.0
 * @since 2025-01-01
 */
public enum SocialPlatform {
    
    /**
     * Facebook social media platform.
     * Supports posts, stories, business pages, and advertising.
     */
    FACEBOOK("Facebook", "facebook", "https://www.facebook.com"),
    
    /**
     * Instagram social media platform.
     * Supports posts, stories, reels, and IGTV content.
     */
    INSTAGRAM("Instagram", "instagram", "https://www.instagram.com"),
    
    /**
     * Twitter (X) social media platform.
     * Supports tweets, threads, and spaces.
     */
    TWITTER("Twitter", "twitter", "https://twitter.com"),
    
    /**
     * LinkedIn professional social media platform.
     * Supports posts, articles, and professional networking.
     */
    LINKEDIN("LinkedIn", "linkedin", "https://www.linkedin.com"),
    
    /**
     * YouTube video sharing platform.
     * Supports video uploads, shorts, and live streaming.
     */
    YOUTUBE("YouTube", "youtube", "https://www.youtube.com"),
    
    /**
     * TikTok short-form video platform.
     * Supports short videos, effects, and live streaming.
     */
    TIKTOK("TikTok", "tiktok", "https://www.tiktok.com");
    
    private final String displayName;
    private final String apiIdentifier;
    private final String baseUrl;
    
    SocialPlatform(String displayName, String apiIdentifier, String baseUrl) {
        this.displayName = displayName;
        this.apiIdentifier = apiIdentifier;
        this.baseUrl = baseUrl;
    }
    
    /**
     * Gets the human-readable display name of the platform.
     * 
     * @return the display name
     */
    public String getDisplayName() {
        return displayName;
    }
    
    /**
     * Gets the API identifier used in API calls and configurations.
     * 
     * @return the API identifier
     */
    public String getApiIdentifier() {
        return apiIdentifier;
    }
    
    /**
     * Gets the base URL of the platform.
     * 
     * @return the base URL
     */
    public String getBaseUrl() {
        return baseUrl;
    }
    
    /**
     * Finds a platform by its API identifier.
     * 
     * @param apiIdentifier the API identifier to search for
     * @return the matching platform, or null if not found
     */
    public static SocialPlatform fromApiIdentifier(String apiIdentifier) {
        if (apiIdentifier == null) {
            return null;
        }
        
        for (SocialPlatform platform : values()) {
            if (platform.apiIdentifier.equalsIgnoreCase(apiIdentifier)) {
                return platform;
            }
        }
        
        return null;
    }
    
    /**
     * Checks if this platform supports video content.
     * 
     * @return true if the platform supports video content
     */
    public boolean supportsVideo() {
        return switch (this) {
            case YOUTUBE, TIKTOK, INSTAGRAM, FACEBOOK -> true;
            case TWITTER, LINKEDIN -> false;
        };
    }
    
    /**
     * Checks if this platform supports stories.
     * 
     * @return true if the platform supports stories
     */
    public boolean supportsStories() {
        return switch (this) {
            case INSTAGRAM, FACEBOOK -> true;
            case TWITTER, LINKEDIN, YOUTUBE, TIKTOK -> false;
        };
    }
    
    /**
     * Checks if this platform supports live streaming.
     * 
     * @return true if the platform supports live streaming
     */
    public boolean supportsLiveStreaming() {
        return switch (this) {
            case YOUTUBE, INSTAGRAM, FACEBOOK, TIKTOK -> true;
            case TWITTER, LINKEDIN -> false;
        };
    }
    
    /**
     * Gets the maximum character limit for posts on this platform.
     * 
     * @return the character limit, or -1 if no limit
     */
    public int getCharacterLimit() {
        return switch (this) {
            case TWITTER -> 280;
            case LINKEDIN -> 3000;
            case FACEBOOK -> 63206;
            case INSTAGRAM -> 2200;
            case YOUTUBE -> 5000; // For video descriptions
            case TIKTOK -> 300; // For video captions
        };
    }
}
