//
//  PaymentAPI.swift
//  suixinkan
//

import Foundation

@MainActor
/// 收款相关 API，封装摄影师收款码与收款记录接口。
final class PaymentAPI {
    private let client: APIClient

    init(client: APIClient) {
        self.client = client
    }

    /// 拉取当前景区的静态/动态支付 URL。
    func payCode(scenicId: Int) async throws -> PayCodeResponse {
        try await client.send(
            APIRequest(
                method: .get,
                path: "/api/yf-handset-app/photog/pay-code",
                queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))]
            )
        )
    }

    /// 拉取当前景区收款页的背景、Logo 与标题配置。
    func payPageConfig(scenicId: Int) async throws -> PayPageConfigResponse {
        try await client.send(
            APIRequest(
                method: .get,
                path: "/api/yf-handset-app/photog/pay-page-config",
                queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))]
            )
        )
    }

    /// 拉取近 7 天收款记录。
    func collectionRecord(scenicId: Int) async throws -> RepaymentCollectionRecordResponse {
        try await client.send(
            APIRequest(
                method: .get,
                path: "/api/yf-handset-app/photog/order/photo-scan-order-list",
                queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))]
            )
        )
    }
}
