//
//  LiveRepository.swift
//  SodaLive
//
//  Created by klaus on 2023/08/09.
//

import Foundation
import CombineMoya
import Combine
import Moya

final class LiveRepository {
    private let api = MoyaProvider<LiveApi>()
    
    func roomList(request: GetRoomListRequest) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.roomList(request: request))
    }
    
    func recentVisitRoomUsers() -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.recentVisitRoomUsers)
    }
    
    func getReservations(isActive: Bool) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getReservations(isActive: isActive))
    }
    
    func getReservation(reservationId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getReservation(reservationId: reservationId))
    }
    
    func cancelReservation(reservationId: Int, reason: String) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.cancelReservation(request: CancelLiveReservationRequest(reservationId: reservationId, reason: reason)))
    }
}
