punchnet-macos/punchnet/Features/Network/NetworkService.swift
2026-04-17 15:32:49 +08:00

35 lines
986 B
Swift

//
// SDLAPIClient+Network.swift
// punchnet
//
// Created by on 2026/3/24.
//
import Foundation
struct NetworkService {
static func connectNetwork(accesToken: String) async throws -> NetworkContext {
let params: [String: Any] = [
"client_id": SystemConfig.getClientId(),
"access_token": accesToken
]
return try await SDLAPIClient.doPost(path: "/connect", params: params, as: NetworkContext.self)
}
static func loadNodeResources(accesToken: String, id: Int) async -> [NetworkContext.Resource] {
let params: [String: Any] = [
"client_id": SystemConfig.getClientId(),
"access_token": accesToken,
"id": id
]
if let detail = try? await SDLAPIClient.doPost(path: "/get_node_resources", params: params, as: NetworkContext.NodeDetail.self) {
return detail.resourceList
}
return []
}
}