Files
suixinkan_ios_new/suixinkan/Features/Profile/API/ProfileAPI.swift
汉秋 d2fe5d71e4 Add TravelAlbum, ProfileSpace, and wired camera transfer modules.
Introduce travel album entry with Sony PTP tethering pipeline, profile space settings page, home routing updates, Launch Screen storyboard, and related tests/docs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 09:41:05 +08:00

137 lines
4.3 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.

//
// ProfileAPI.swift
// suixinkan
//
// Created by Codex on 2026/6/20.
//
import Foundation
import Combine
@MainActor
/// API 便 ViewModel 使
protocol ProfileSpaceServing {
///
func profileSpaceInfo(scenicId: Int) async throws -> ProfileSpaceInfoResponse
///
func updateProfileSpaceInfo(_ request: UpdateProfileSpaceRequest) async throws
///
func updateUserInfo(nickname: String?, password: String?, avatar: String?) async throws
/// URL
func updateUserAvatarURL(_ fileURL: String) async throws
}
@MainActor
/// API
final class ProfileAPI {
private let client: APIClient
/// API
init(client: APIClient) {
self.client = client
}
///
func userInfo() async throws -> UserInfoResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/userinfo"
)
)
}
///
func switchableAccounts() async throws -> V9AuthResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/app/v9/accounts"
)
)
}
///
func realNameInfo() async throws -> RealNameInfoResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/real-name/info"
)
)
}
///
func updateUserInfo(nickname: String? = nil, password: String? = nil, avatar: String? = nil) async throws {
let request = UpdateInfoRequest(nickname: nickname, password: password, avatar: avatar)
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/userinfo-update",
body: request
)
)
}
/// URL OSS
func updateUserAvatarURL(_ fileURL: String) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/userinfo-update-avatar-url",
queryItems: [URLQueryItem(name: "file_url", value: fileURL)]
)
)
}
///
func profileSpaceInfo(scenicId: Int) async throws -> ProfileSpaceInfoResponse {
try await client.send(
APIRequest(
method: .get,
path: "/api/yf-handset-app/photog/profile/info",
queryItems: [URLQueryItem(name: "scenic_id", value: "\(scenicId)")]
)
)
}
///
func updateProfileSpaceInfo(_ request: UpdateProfileSpaceRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/profile/info-update",
body: request
)
)
}
///
func realNameSmsVerifyCode() async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/real-name/sms-verify-code",
body: EmptyPayload()
)
)
}
///
func realNameSubmit(_ request: RealNameAuthRequest) async throws {
let _: EmptyPayload = try await client.send(
APIRequest(
method: .post,
path: "/api/yf-handset-app/photog/real-name/submit",
body: request
)
)
}
}
extension ProfileAPI: UserProfileServing {}
extension ProfileAPI: ProfileSpaceServing {}