package com.optix.android.domain.usecase

import com.optix.android.domain.model.Session
import com.optix.android.domain.repository.SessionRepository
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class SessionUseCase @Inject constructor(
    private val sessionRepository: SessionRepository,
) {
    suspend fun save(session: Session): Long = sessionRepository.saveSession(session)

    suspend fun get(id: Long): Session? = sessionRepository.getSession(id)

    fun getAll(): Flow<List<Session>> = sessionRepository.getAllSessions()

    fun getByTool(toolSlug: String): Flow<List<Session>> =
        sessionRepository.getSessionsByTool(toolSlug)

    suspend fun delete(id: Long) = sessionRepository.deleteSession(id)

    fun export(session: Session): String = sessionRepository.exportToJson(session)

    fun import(json: String): Session? = sessionRepository.importFromJson(json)
}
