feat(content): 추천 전체보기를 연결한다

This commit is contained in:
Yu Sung
2026-07-07 11:54:31 +09:00
parent b33aed94c6
commit 981c02a8e1
18 changed files with 1169 additions and 294 deletions

View File

@@ -0,0 +1,44 @@
import Foundation
import Moya
enum ContentOverviewApi {
case getContents(type: ContentOverviewType, page: Int, size: Int)
}
extension ContentOverviewApi: TargetType {
var baseURL: URL {
return URL(string: BASE_URL)!
}
var path: String {
switch self {
case .getContents:
return "/api/v2/contents"
}
}
var method: Moya.Method {
switch self {
case .getContents:
return .get
}
}
var task: Moya.Task {
switch self {
case .getContents(let type, let page, let size):
return .requestParameters(
parameters: [
"page": page,
"size": size,
"type": type.rawValue
],
encoding: URLEncoding.queryString
)
}
}
var headers: [String: String]? {
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
}
}

View File

@@ -0,0 +1,16 @@
import Foundation
import Combine
import CombineMoya
import Moya
final class ContentOverviewRepository {
private let api = MoyaProvider<ContentOverviewApi>()
func getContents(
type: ContentOverviewType,
page: Int,
size: Int
) -> AnyPublisher<Response, MoyaError> {
return api.requestPublisher(.getContents(type: type, page: page, size: size))
}
}