From 3e11d82938cc497f63f09ab8e394766bda4c63af Mon Sep 17 00:00:00 2001 From: Yu Sung Date: Sat, 4 Jul 2026 22:44:31 +0900 Subject: [PATCH] =?UTF-8?q?feat(creator):=20=ED=9B=84=EC=9B=90=20=ED=83=AD?= =?UTF-8?q?=20API=EB=A5=BC=20=EC=B6=94=EA=B0=80=ED=95=9C=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CreatorChannelDonationTabResponse.swift | 17 +++++++ .../CreatorChannelDonationApi.swift | 44 +++++++++++++++++++ .../CreatorChannelDonationRepository.swift | 13 ++++++ 3 files changed, 74 insertions(+) create mode 100644 SodaLive/Sources/V2/CreatorChannel/Donation/Models/CreatorChannelDonationTabResponse.swift create mode 100644 SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationApi.swift create mode 100644 SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationRepository.swift diff --git a/SodaLive/Sources/V2/CreatorChannel/Donation/Models/CreatorChannelDonationTabResponse.swift b/SodaLive/Sources/V2/CreatorChannel/Donation/Models/CreatorChannelDonationTabResponse.swift new file mode 100644 index 00000000..4bb08f0f --- /dev/null +++ b/SodaLive/Sources/V2/CreatorChannel/Donation/Models/CreatorChannelDonationTabResponse.swift @@ -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 +} diff --git a/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationApi.swift b/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationApi.swift new file mode 100644 index 00000000..df4ed236 --- /dev/null +++ b/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationApi.swift @@ -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))"] + } +} diff --git a/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationRepository.swift b/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationRepository.swift new file mode 100644 index 00000000..2a5b040e --- /dev/null +++ b/SodaLive/Sources/V2/CreatorChannel/Donation/Repository/CreatorChannelDonationRepository.swift @@ -0,0 +1,13 @@ +import Foundation +import Combine + +import CombineMoya +import Moya + +final class CreatorChannelDonationRepository { + private let api = MoyaProvider() + + func getDonations(creatorId: Int, page: Int, size: Int) -> AnyPublisher { + return api.requestPublisher(.getDonations(creatorId: creatorId, page: page, size: size)) + } +}