package kr.co.vividnext.sodalive.explorer

import kr.co.vividnext.sodalive.explorer.profile.PostCreatorNoticeRequest
import kr.co.vividnext.sodalive.explorer.profile.cheers.PostWriteCheersRequest
import kr.co.vividnext.sodalive.explorer.profile.cheers.PutModifyCheersRequest
import java.util.TimeZone

class ExplorerRepository(
    private val api: ExplorerApi
) {
    fun getExplorer(token: String) = api.getExplorer(authHeader = token)

    fun searchChannel(channel: String, token: String) = api.searchChannel(
        channel = channel,
        authHeader = token
    )

    fun getCreatorProfile(id: Long, token: String) = api.getCreatorProfile(
        id = id,
        timezone = TimeZone.getDefault().id,
        authHeader = token
    )

    fun writeCheers(
        parentCheersId: Long?,
        creatorId: Long,
        content: String,
        token: String
    ) = api.writeCheers(
        request = PostWriteCheersRequest(
            parentId = parentCheersId,
            creatorId = creatorId,
            content = content
        ),
        authHeader = token
    )

    fun modifyCheers(
        cheersId: Long,
        content: String,
        token: String
    ) = api.modifyCheers(
        request = PutModifyCheersRequest(
            cheersId = cheersId,
            content = content
        ),
        authHeader = token
    )

    fun writeCreatorNotice(notice: String, token: String) = api.writeCreatorNotice(
        request = PostCreatorNoticeRequest(notice),
        authHeader = token
    )

    fun getFollowerList(
        userId: Long,
        page: Int,
        size: Int,
        token: String
    ) = api.getFollowerList(
        userId = userId,
        page = page - 1,
        size = size,
        authHeader = token
    )
}
