feat(creator): 커뮤니티 탭을 추가한다
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
|
||||
import Moya
|
||||
|
||||
enum CreatorChannelCommunityApi {
|
||||
case getCommunity(creatorId: Int, page: Int, size: Int)
|
||||
}
|
||||
|
||||
extension CreatorChannelCommunityApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getCommunity(let creatorId, _, _):
|
||||
return "/api/v2/creator-channels/\(creatorId)/community"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .getCommunity:
|
||||
return .get
|
||||
}
|
||||
}
|
||||
|
||||
var task: Moya.Task {
|
||||
switch self {
|
||||
case .getCommunity(_, let page, let size):
|
||||
return .requestParameters(
|
||||
parameters: ["page": page, "size": size],
|
||||
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 CreatorChannelCommunityRepository {
|
||||
private let api = MoyaProvider<CreatorChannelCommunityApi>()
|
||||
|
||||
func getCommunity(creatorId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getCommunity(creatorId: creatorId, page: page, size: size))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user