package com.social.media.service;

import com.social.media.dto.SocialAccountDto;
import com.social.media.domain.shared.PageResponse;
import com.social.media.domain.entity.SocialAccount;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public interface SocialAccountService {
    
    // CRUD Operations
    PageResponse<SocialAccountDto> getAllSocialAccounts(int page, int size);
    
    SocialAccountDto getSocialAccountById(Long id);
    
    SocialAccountDto createSocialAccount(SocialAccountDto socialAccountDto);
    
    SocialAccountDto updateSocialAccount(Long id, SocialAccountDto socialAccountDto);
    
    void deleteSocialAccount(Long id);
    
    // Company-based queries
    PageResponse<SocialAccountDto> getAccountsByCompany(Long companyId, int page, int size);
    
    PageResponse<SocialAccountDto> getActiveAccountsByCompany(Long companyId, int page, int size);
    
    PageResponse<SocialAccountDto> getConnectedAccountsByCompany(Long companyId, int page, int size);
    
    // Social network queries
    PageResponse<SocialAccountDto> getAccountsBySocialNetwork(Long socialNetworkId, int page, int size);
    
    // User-based queries
    PageResponse<SocialAccountDto> getAccountsByResponsibleUser(Long responsibleUserId, int page, int size);
    
    // Search and filtering
    PageResponse<SocialAccountDto> searchAccountsByUsername(String username, int page, int size);
    
    PageResponse<SocialAccountDto> searchAccountsByNameOrUsername(Long companyId, String searchTerm, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsByConnectionStatus(Long companyId, SocialAccount.ConnectionStatus status, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsByEngagementRange(Double minEngagement, Double maxEngagement, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsByFollowersRange(Integer minFollowers, Integer maxFollowers, int page, int size);
    
    // Analytics and metrics
    PageResponse<SocialAccountDto> getTopAccountsByFollowers(Long companyId, int page, int size);
    
    PageResponse<SocialAccountDto> getTopAccountsByEngagement(Long companyId, int page, int size);
    
    Long getTotalFollowersByCompany(Long companyId);
    
    Double getAverageEngagementByCompany(Long companyId);
    
    List<SocialAccountDto> getAccountsReachingFollowerTargets();
    
    List<SocialAccountDto> getAccountsReachingEngagementTargets();
    
    List<Object[]> getConnectedAccountsSummaryByCompany(Long companyId);
    
    // Account management
    SocialAccountDto connectAccount(Long id, Map<String, Object> connectionData);
    
    SocialAccountDto disconnectAccount(Long id);
    
    SocialAccountDto syncAccount(Long id);
    
    List<SocialAccountDto> syncAccountsForCompany(Long companyId);
    
    List<SocialAccountDto> getAccountsNeedingSync();
    
    // Validation and checks
    boolean existsByAccountCode(String accountCode);
    
    boolean existsByCompanyAndSocialNetworkAndUsername(Long companyId, Long socialNetworkId, String username);
    
    // Metrics and performance
    SocialAccountDto updateAccountMetrics(Long id, Map<String, Object> metrics);
    
    List<SocialAccountDto> getLowPerformingAccounts();
    
    List<SocialAccountDto> getAccountsWithStaleMetrics(LocalDateTime cutoffDate);
    
    // Filtering by account properties
    PageResponse<SocialAccountDto> getVerifiedAccounts(int page, int size);
    
    PageResponse<SocialAccountDto> getBusinessAccounts(Long companyId, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsByType(String accountType, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsByCategory(String businessCategory, int page, int size);
    
    PageResponse<SocialAccountDto> getAccountsWithSyncErrors(int page, int size);
    
    // Statistics
    Long countAccountsByCompany(Long companyId);
    
    Long countActiveAccountsByCompany(Long companyId);
    
    Long countConnectedAccountsByCompany(Long companyId);
    
    Long countAccountsBySocialNetwork(Long socialNetworkId);
}
