//
//  MessageRepository.swift
//  SodaLive
//
//  Created by klaus on 2023/08/10.
//

import Foundation
import CombineMoya
import Combine
import Moya

final class MessageRepository {
    private let api = MoyaProvider<MessageApi>()
    
    func getReceivedTextMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getReceivedTextMessage(page: page, size: size))
    }
    
    func getSentTextMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getSentTextMessage(page: page, size: size))
    }
    
    func getKeepTextMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getKeepTextMessage(page: page, size: size))
    }
    
    func sendTextMessage(request: SendTextMessageRequest) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.sendTextMessage(request:request))
    }
    
    func keepTextMessage(messageId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.keepTextMessage(messageId: messageId))
    }
    
    func getReceivedVoiceMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getReceivedVoiceMessage(page: page, size: size))
    }
    
    func getSentVoiceMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getSentVoiceMessage(page: page, size: size))
    }
    
    func getKeepVoiceMessage(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.getKeepVoiceMessage(page: page, size: size))
    }
    
    func sendVoiceMessage(parameters: [MultipartFormData]) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.sendVoiceMessage(parameters: parameters))
    }
    
    func keepVoiceMessage(messageId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.keepVoiceMessage(messageId: messageId))
    }
    
    func deleteMessage(messageId: Int) -> AnyPublisher<Response, MoyaError> {
        return api.requestPublisher(.deleteMessage(messageId: messageId))
    }
}
