feat(content): 전체 탭을 추가한다

This commit is contained in:
Yu Sung
2026-07-06 16:28:33 +09:00
parent b42ca61ce4
commit bae92eba4b
14 changed files with 1233 additions and 1 deletions

View File

@@ -0,0 +1,55 @@
import Foundation
import Moya
enum MainContentAllApi {
case getContents(
type: MainContentAllType,
sort: ContentSort,
page: Int,
size: Int,
dayOfWeek: SeriesPublishedDaysOfWeek
)
}
extension MainContentAllApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getContents:
return "/api/v2/audio/contents"
}
}
var method: Moya.Method {
switch self {
case .getContents:
return .get
}
}
var task: Moya.Task {
switch self {
case .getContents(let type, let sort, let page, let size, let dayOfWeek):
var parameters: [String: Any] = [
"type": type.rawValue,
"sort": sort.rawValue,
"page": page,
"size": size
]
if type == .series {
parameters["dayOfWeek"] = dayOfWeek.rawValue
}
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 MainContentAllRepository {
private let api = MoyaProvider<MainContentAllApi>()
func getContents(
type: MainContentAllType,
sort: ContentSort,
page: Int,
size: Int,
dayOfWeek: SeriesPublishedDaysOfWeek
) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(
.getContents(
type: type,
sort: sort,
page: page,
size: size,
dayOfWeek: dayOfWeek
)
)
}
}