//
//  SDLAPIClient+App.swift
//  punchnet
//
//  Created by 安礼成 on 2026/3/21.
//
import Foundation

struct AppService {
    
    // 提交用户反馈
    static func appIssue(accessToken: String, contact: String, content: String) async throws -> String {
        let params: [String: Any] = [
            "access_token": accessToken,
            "contact": contact,
            "platform": SystemConfig.systemInfo,
            "content": content,
            "client_id": SystemConfig.getClientId(),
            "mac": SystemConfig.macAddressString(mac: SystemConfig.getMacAddress())
        ]
        
        return try await SDLAPIClient.doPost(path: "/app/issue", params: params, as: String.self)
    }
    
    // 隐私和服务政策
    static func appPolicies() async throws -> AppPoliciesInfo {
        let params: [String: Any] = [
            "platform": "macos",
            "client_id": SystemConfig.getClientId()
        ]
        return try await SDLAPIClient.doPost(path: "/app/policies", params: params, as: AppPoliciesInfo.self)
    }
    
    // 检查app升级
    static func appCheckUpdate() async throws -> AppUpgradeInfo {
        let params: [String: Any] = [
            "app_id": "Punchnet",
            "platform": "macos",
            "version": SystemConfig.systemInfo,
            "build": SystemConfig.build,
            "channel": SystemConfig.channel,
            "client_id": SystemConfig.getClientId()
        ]
        return try await SDLAPIClient.doPost(path: "/app/checkUpdate", params: params, as: AppUpgradeInfo.self)
    }
    
}
