84 lines
3.6 KiB
Swift
84 lines
3.6 KiB
Swift
//
|
|
// ContentRepository.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2023/08/11.
|
|
//
|
|
|
|
import Foundation
|
|
import CombineMoya
|
|
import Combine
|
|
import Moya
|
|
|
|
final class ContentRepository {
|
|
private let api = MoyaProvider<ContentApi>()
|
|
|
|
func getAudioContentList(userId: Int, page: Int, size: Int, sort: ContentListViewModel.Sort) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getAudioContentList(userId: userId, page: page, size: size, sort: sort))
|
|
}
|
|
|
|
func getAudioContentDetail(audioContentId: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getAudioContentDetail(audioContentId: audioContentId))
|
|
}
|
|
|
|
func likeContent(audioContentId: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.likeContent(request: PutAudioContentLikeRequest(contentId: audioContentId)))
|
|
}
|
|
|
|
func registerComment(audioContentId: Int, comment: String, parentId: Int? = nil) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.registerComment(request: RegisterAudioContentCommentRequest(comment: comment, contentId: audioContentId, parentId: parentId)))
|
|
}
|
|
|
|
func orderAudioContent(contentId: Int, orderType: OrderType) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.orderAudioContent(request: OrderRequest(contentId: contentId, orderType: orderType)))
|
|
}
|
|
|
|
func getOrderList(page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getOrderList(page: page, size: size))
|
|
}
|
|
|
|
func addAllPlaybackTracking(request: AddAllPlaybackTrackingRequest) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.addAllPlaybackTracking(request: request))
|
|
}
|
|
|
|
func getAudioContentThemeList() -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getAudioContentThemeList)
|
|
}
|
|
|
|
func uploadAudioContent(parameters: [MultipartFormData]) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.uploadAudioContent(parameters: parameters))
|
|
}
|
|
|
|
func getAudioContentCommentList(audioContentId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getAudioContentCommentList(audioContentId: audioContentId, page: page, size: size))
|
|
}
|
|
|
|
func getAudioContentCommentReplyList(commentId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getAudioContentCommentReplyList(commentId: commentId, page: page, size: size))
|
|
}
|
|
|
|
func deleteAudioContent(audioContentId: Int) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.deleteAudioContent(audioContentId: audioContentId))
|
|
}
|
|
|
|
func modifyAudioContent(parameters: [MultipartFormData]) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.modifyAudioContent(parameters: parameters))
|
|
}
|
|
|
|
func getMain() -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getMain)
|
|
}
|
|
|
|
func getNewContentOfTheme(theme: String) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.getNewContentOfTheme(theme: theme))
|
|
}
|
|
|
|
func donation(contentId: Int, can: Int, comment: String) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.donation(request: AudioContentDonationRequest(contentId: contentId, donationCan: can, comment: comment)))
|
|
}
|
|
|
|
func modifyComment(request: ModifyCommentRequest) -> AnyPublisher<Response, MoyaError> {
|
|
return api.requestPublisher(.modifyComment(request: request))
|
|
}
|
|
}
|