package kr.co.vividnext.sodalive.live.roulette

import io.reactivex.rxjava3.core.Single
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.live.roulette.config.CreateRouletteRequest
import kr.co.vividnext.sodalive.live.roulette.config.RouletteApi
import kr.co.vividnext.sodalive.live.roulette.config.UpdateRouletteRequest

class RouletteRepository(private val api: RouletteApi) {
    fun createRoulette(
        request: CreateRouletteRequest,
        token: String
    ) = api.createRoulette(
        request = request,
        authHeader = token
    )

    fun updateRoulette(
        request: UpdateRouletteRequest,
        token: String
    ) = api.updateRoulette(
        request = request,
        authHeader = token
    )

    fun getAllRoulette(creatorId: Long, token: String) = api.getAllRoulette(
        creatorId = creatorId,
        authHeader = token
    )

    fun getRoulette(creatorId: Long, token: String) = api.getRoulette(
        creatorId = creatorId,
        authHeader = token
    )

    fun spinRoulette(request: SpinRouletteRequest, token: String) = api.spinRoulette(
        request = request,
        authHeader = token
    )

    fun refundRouletteDonation(roomId: Long, token: String): Single<ApiResponse<Any>> {
        return api.refundRouletteDonation(
            id = roomId,
            authHeader = token
        )
    }
}
