package kr.co.vividnext.sodalive.audio_content.comment

import kr.co.vividnext.sodalive.audio_content.AudioContentApi
import java.util.TimeZone

class AudioContentCommentRepository(private val api: AudioContentApi) {
    fun registerComment(
        contentId: Long,
        comment: String,
        parentId: Long? = null,
        isSecret: Boolean = false,
        token: String
    ) = api.registerComment(
        request = RegisterAudioContentCommentRequest(
            comment = comment,
            contentId = contentId,
            parentId = parentId,
            isSecret = isSecret
        ),
        authHeader = token
    )

    fun getAudioContentCommentList(
        audioContentId: Long,
        page: Int,
        size: Int,
        token: String
    ) = api.getAudioContentCommentList(
        id = audioContentId,
        page = page - 1,
        size = size,
        timezone = TimeZone.getDefault().id,
        authHeader = token
    )

    fun getAudioContentCommentReplyList(
        commentId: Long,
        page: Int,
        size: Int,
        token: String
    ) = api.getAudioContentCommentCommentList(
        id = commentId,
        page = page - 1,
        size = size,
        timezone = TimeZone.getDefault().id,
        authHeader = token
    )

    fun modifyComment(request: ModifyCommentRequest, token: String) = api.modifyComment(
        request = request,
        authHeader = token
    )
}
