Files
suixinkan_uikit/suixinkan/Features/Wallet/API/WalletAPI.swift

68 lines
2.0 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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)),
]
)
)
}
}