feat(creator): 라이브 탭 기반을 추가한다
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
|
||||
import Moya
|
||||
|
||||
enum CreatorChannelLiveApi {
|
||||
case getLive(creatorId: Int, page: Int, size: Int, sort: ContentSort)
|
||||
}
|
||||
|
||||
extension CreatorChannelLiveApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getLive(let creatorId, _, _, _):
|
||||
return "/api/v2/creator-channels/\(creatorId)/live"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .getLive:
|
||||
return .get
|
||||
}
|
||||
}
|
||||
|
||||
var task: Moya.Task {
|
||||
switch self {
|
||||
case .getLive(_, let page, let size, let sort):
|
||||
return .requestParameters(
|
||||
parameters: ["page": page, "size": size, "sort": sort.rawValue],
|
||||
encoding: URLEncoding.queryString
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
var headers: [String: String]? {
|
||||
return ["Authorization": "Bearer \(UserDefaults.string(forKey: UserDefaultsKey.token))"]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import Foundation
|
||||
import Combine
|
||||
|
||||
import CombineMoya
|
||||
import Moya
|
||||
|
||||
final class CreatorChannelLiveRepository {
|
||||
private let api = MoyaProvider<CreatorChannelLiveApi>()
|
||||
|
||||
func getLive(creatorId: Int, page: Int, size: Int, sort: ContentSort) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getLive(creatorId: creatorId, page: page, size: size, sort: sort))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user