Files
e-party-iOS/yana/APIs/APIEndpoints.swift
2025-07-07 14:19:07 +08:00

85 lines
2.5 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.

import Foundation
// MARK: - API Endpoints
/// API
///
/// API
/// 使
///
/// case
///
/// 使
/// ```swift
/// let configPath = APIEndpoint.config.path // "/client/config"
/// ```
enum APIEndpoint: String, CaseIterable {
case config = "/client/config"
case configInit = "/client/init"
case login = "/auth/login"
//
var path: String {
return self.rawValue
}
}
// MARK: - API Configuration
/// API
///
/// API
/// -
/// -
/// -
/// -
///
///
/// -
/// -
/// -
struct APIConfiguration {
static let baseURL = "http://beta.api.molistar.xyz"
static let timeout: TimeInterval = 30.0
static let maxDataSize: Int = 50 * 1024 * 1024 // 50MB
///
///
/// API
/// - Content-Type Accept
/// -
/// -
/// -
///
///
static var defaultHeaders: [String: String] {
var headers = [
"Content-Type": "application/json",
"Accept": "application/json",
"Accept-Encoding": "gzip, br",
"Accept-Language": Locale.current.languageCode ?? "en",
"App-Version": Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "1.0.0"
]
// headers
if let userId = UserInfoManager.getCurrentUserId() {
headers["pub_uid"] = userId
}
if let userTicket = UserInfoManager.getCurrentUserTicket() {
headers["pub_ticket"] = userTicket
}
return headers
}
}
// MARK: - Request Models
struct LoginRequest: Codable {
let username: String
let password: String
}
// MARK: - Empty Request
struct EmptyRequest: Codable {}