Files
suixinkan_uikit/suixinkan/Features/Task/API/TaskAPI.swift

82 lines
2.6 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.

//
// TaskAPI.swift
// suixinkan
//
import Foundation
@MainActor
/// API
final class TaskAPI {
private let client: APIClient
init(client: APIClient) {
self.client = client
}
///
func createTask(_ request: AddTaskRequest) async throws {
let _: EmptyResponse = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/task/create",
body: request
)
)
}
///
func availableOrders(scenicId: Int) async throws -> [AvailableOrder] {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/task/available-order",
queryItems: [URLQueryItem(name: "scenic_id", value: String(scenicId))]
)
)
}
///
func cloudFileList(
parentFolderId: Int,
name: String = "",
type: Int = 0,
orderBy: Int = 2,
page: Int = 1,
pageSize: Int = 20
) async throws -> CloudFileListResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/cloud-driver/list",
queryItems: [
URLQueryItem(name: "parent_folder_id", value: String(parentFolderId)),
URLQueryItem(name: "name", value: name),
URLQueryItem(name: "type", value: String(type)),
URLQueryItem(name: "order_by", value: String(orderBy)),
URLQueryItem(name: "page", value: String(page)),
URLQueryItem(name: "page_size", value: String(pageSize)),
]
)
)
}
/// OSS URL
func registerUploadedFileURL(scenicId: Int, fileURL: String, folderId: Int = 0) async throws {
let _: EmptyResponse = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/album/file-upload-url",
queryItems: [
URLQueryItem(name: "scenic_id", value: String(scenicId)),
URLQueryItem(name: "file_url", value: fileURL),
URLQueryItem(name: "folder_id", value: String(folderId)),
]
)
)
}
}
/// data
private struct EmptyResponse: Decodable, Sendable {}