47 lines
1.4 KiB
Swift
47 lines
1.4 KiB
Swift
//
|
|
// InviteAPI.swift
|
|
// suixinkan
|
|
//
|
|
|
|
import Foundation
|
|
|
|
@MainActor
|
|
/// 邀请服务协议,抽象邀请信息与邀请用户列表接口。
|
|
protocol InviteServing {
|
|
/// 获取邀请二维码、邀请码和规则信息。
|
|
func inviteInfo() async throws -> InviteInfoResponse
|
|
|
|
/// 获取邀请用户列表。
|
|
func inviteUserList(page: Int, pageSize: Int) async throws -> [InviteUserItem]
|
|
}
|
|
|
|
@MainActor
|
|
/// 邀请 API,封装摄影师注册邀请相关接口。
|
|
final class InviteAPI: InviteServing {
|
|
private let client: APIClient
|
|
|
|
/// 初始化邀请 API。
|
|
init(client: APIClient) {
|
|
self.client = client
|
|
}
|
|
|
|
/// 获取邀请二维码、邀请码和规则信息。
|
|
func inviteInfo() async throws -> InviteInfoResponse {
|
|
try await client.send(APIRequest(method: .get, path: "/api/yf-handset-app/photog/invite-info"))
|
|
}
|
|
|
|
/// 获取邀请用户列表。
|
|
func inviteUserList(page: Int = 1, pageSize: Int = 20) async throws -> [InviteUserItem] {
|
|
try await client.send(
|
|
APIRequest(
|
|
method: .get,
|
|
path: "/api/yf-handset-app/photog/invite/user-list",
|
|
queryItems: [
|
|
URLQueryItem(name: "page", value: String(max(page, 1))),
|
|
URLQueryItem(name: "page_size", value: String(max(pageSize, 1))),
|
|
]
|
|
)
|
|
)
|
|
}
|
|
}
|