feat(creator): 오디오 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-04 16:40:35 +09:00
parent 6600cd43c1
commit c4c18341a6
12 changed files with 955 additions and 77 deletions

View File

@@ -0,0 +1,48 @@
import Foundation
import Moya
enum CreatorChannelAudioApi {
case getAudio(creatorId: Int, page: Int, size: Int, sort: ContentSort, themeId: Int?)
}
extension CreatorChannelAudioApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getAudio(let creatorId, _, _, _, _):
return "/api/v2/creator-channels/\(creatorId)/audio"
}
}
var method: Moya.Method {
switch self {
case .getAudio:
return .get
}
}
var task: Moya.Task {
switch self {
case .getAudio(_, let page, let size, let sort, let themeId):
var parameters: [String: Any] = [
"page": page,
"size": size,
"sort": sort.rawValue
]
if let themeId {
parameters["themeId"] = themeId
}
return .requestParameters(parameters: parameters, encoding: URLEncoding.queryString)
}
}
var headers: [String: String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}

View File

@@ -0,0 +1,27 @@
import Foundation
import Combine
import CombineMoya
import Moya
final class CreatorChannelAudioRepository {
private let api = MoyaProvider<CreatorChannelAudioApi>()
func getAudio(
creatorId: Int,
page: Int,
size: Int,
sort: ContentSort,
themeId: Int?
) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(
.getAudio(
creatorId: creatorId,
page: page,
size: size,
sort: sort,
themeId: themeId
)
)
}
}