//
//  AuditionRepository.swift
//  SodaLive
//
//  Created by klaus on 1/5/25.
//

import Foundation
import CombineMoya
import Combine
import Moya

final class AuditionRepository {
    private let api = MoyaProvider<AuditionApi>()
    
    func getAuditionList(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getAuditionList(page: page, size: size))
    }
    
    func getAuditionDetail(auditionId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getAuditionDetail(auditionId: auditionId))
    }
    
    func getAuditionRoleDetail(auditionRoleId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getAuditionRoleDetail(auditionRoleId: auditionRoleId))
    }
    
    func getAuditionApplicantList(auditionRoleId: Int, sortType: AuditionApplicantSortType, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(
            .getAuditionApplicantList(
                auditionRoleId: auditionRoleId,
                sortType: sortType,
                page: page,
                size: size
            )
        )
    }
    
    func applyAudition(parameters: [MultipartFormData]) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.applyAudition(parameters: parameters))
    }
}
