// // WalletAPI.swift // suixinkan // import Foundation @MainActor /// 钱包服务协议,提供邀请奖励记录所需的汇总与流水接口。 protocol WalletServing { /// 获取钱包汇总金额,`type = 2` 表示邀请奖励。 func walletSummary(type: Int) async throws -> WalletSummaryResponse /// 获取钱包流水列表。 func walletTransactionList( startDate: String, endDate: String, page: Int, pageSize: Int, type: Int ) async throws -> WalletTransactionListResponse } @MainActor /// 钱包 API,封装邀请奖励记录所需的最小接口集合。 final class WalletAPI: WalletServing { private let client: APIClient /// 初始化钱包 API。 init(client: APIClient) { self.client = client } /// 获取钱包汇总金额。 func walletSummary(type: Int = 0) async throws -> WalletSummaryResponse { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/wallet/summary", queryItems: [URLQueryItem(name: "type", value: String(type))] ) ) } /// 获取钱包流水列表。 func walletTransactionList( startDate: String, endDate: String, page: Int = 1, pageSize: Int = 10, type: Int = 2 ) async throws -> WalletTransactionListResponse { try await client.send( APIRequest( method: .get, path: "/api/yf-handset-app/photog/wallet/transaction-list", queryItems: [ URLQueryItem(name: "start_date", value: startDate), URLQueryItem(name: "end_date", value: endDate), URLQueryItem(name: "page", value: String(max(page, 1))), URLQueryItem(name: "page_size", value: String(max(pageSize, 1))), URLQueryItem(name: "type", value: String(type)), ] ) ) } }