Files
suixinkan_uikit/suixinkan/App/NetworkServices.swift

33 lines
840 B
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.

//
// NetworkServices.swift
// suixinkan
//
import Foundation
@MainActor
/// APIClient AuthAPI
final class NetworkServices {
static let shared = NetworkServices()
let apiClient: APIClient
let authAPI: AuthAPI
///
private init() {
let client = APIClient(environment: .current)
apiClient = client
authAPI = AuthAPI(client: client)
client.bindAuthTokenProvider {
let token = AppStore.shared.token.trimmingCharacters(in: .whitespacesAndNewlines)
return token.isEmpty ? nil : token
}
}
/// mock `APIClient`
init(apiClient: APIClient) {
self.apiClient = apiClient
authAPI = AuthAPI(client: apiClient)
}
}