//
//  RouletteRepository.swift
//  SodaLive
//
//  Created by klaus on 2023/12/06.
//

import Foundation
import CombineMoya
import Combine
import Moya

final class RouletteRepository {
    private let api = MoyaProvider<RouletteApi>()
    
    func getRoulette(creatorId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getRoulette(creatorId: creatorId))
    }
    
    func getAllRoulette(creatorId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getAllRoulette(creatorId: creatorId))
    }
    
    func createRoulette(request: CreateRouletteRequest) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.createRoulette(request: request))
    }
    
    func updateRoulette(request: UpdateRouletteRequest) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.updateRoulette(request: request))
    }
    
    func spinRoulette(request: SpinRouletteRequest) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.spinRoulette(request: request))
    }
    
    func refundRouletteDonation(roomId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.refundRouletteDonation(roomId: roomId))
    }
}

