feat(content): 전체 탭을 추가한다
This commit is contained in:
@@ -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))"]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user