package com.syncflow.data.providers

import com.syncflow.data.providers.dropbox.DropboxProvider
import com.syncflow.data.providers.google.GoogleDriveProvider
import com.syncflow.data.providers.nextcloud.NextcloudProvider
import com.syncflow.data.providers.owncloud.OwnCloudProvider
import com.syncflow.data.providers.onedrive.OneDriveProvider
import com.syncflow.data.providers.sftp.SftpProvider
import com.syncflow.data.providers.webdav.WebDavProvider
import com.syncflow.data.security.CredentialStore
import com.syncflow.domain.model.CloudAccount
import com.syncflow.domain.model.ProviderType
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class ProviderFactory @Inject constructor(private val credentialStore: CredentialStore) {
    fun create(account: CloudAccount): CloudProvider = when (account.providerType) {
        ProviderType.GOOGLE_DRIVE -> GoogleDriveProvider(account)
        ProviderType.DROPBOX -> DropboxProvider(account)
        ProviderType.ONEDRIVE -> OneDriveProvider(account)
        ProviderType.WEBDAV -> WebDavProvider(account)
        ProviderType.SFTP -> SftpProvider(account, credentialStore)
        ProviderType.NEXTCLOUD -> NextcloudProvider(account)
        ProviderType.OWNCLOUD -> OwnCloudProvider(account)
        ProviderType.SFTPGO -> WebDavProvider(account)     // SFTPGo exposes WebDAV
    }
}
