feat(creator): 후원 탭 API를 추가한다
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import Foundation
|
||||
|
||||
struct CreatorChannelDonationTabResponse: Decodable {
|
||||
let donationCount: Int
|
||||
let rankings: [MemberDonationRankingResponse]
|
||||
let donations: [CreatorChannelDonationResponse]
|
||||
let page: Int
|
||||
let size: Int
|
||||
let hasNext: Bool
|
||||
}
|
||||
|
||||
struct MemberDonationRankingResponse: Decodable {
|
||||
let userId: Int
|
||||
let nickname: String
|
||||
let profileImage: String
|
||||
let donationCan: Int
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import Foundation
|
||||
|
||||
import Moya
|
||||
|
||||
enum CreatorChannelDonationApi {
|
||||
case getDonations(creatorId: Int, page: Int, size: Int)
|
||||
}
|
||||
|
||||
extension CreatorChannelDonationApi: TargetType {
|
||||
var baseURL: URL {
|
||||
return URL(string: BASE_URL)!
|
||||
}
|
||||
|
||||
var path: String {
|
||||
switch self {
|
||||
case .getDonations(let creatorId, _, _):
|
||||
return "/api/v2/creator-channels/\(creatorId)/donations"
|
||||
}
|
||||
}
|
||||
|
||||
var method: Moya.Method {
|
||||
switch self {
|
||||
case .getDonations:
|
||||
return .get
|
||||
}
|
||||
}
|
||||
|
||||
var task: Moya.Task {
|
||||
switch self {
|
||||
case .getDonations(_, 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 CreatorChannelDonationRepository {
|
||||
private let api = MoyaProvider<CreatorChannelDonationApi>()
|
||||
|
||||
func getDonations(creatorId: Int, page: Int, size: Int) -> AnyPublisher<Response, MoyaError> {
|
||||
return api.requestPublisher(.getDonations(creatorId: creatorId, page: page, size: size))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user