RemoteAuthServiceStub.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import Foundation
  2. /// Remote server adapter placeholder implementing `AuthServiceProtocol`.
  3. /// This stub demonstrates how `CelestiaTrace` can switch to a real remote backend server in the future.
  4. final class RemoteAuthServiceStub: AuthServiceProtocol {
  5. private let baseURL: URL
  6. private let session: URLSession
  7. init(baseURL: URL = URL(string: "https://api.celestiatrace.com/v1")!, session: URLSession = .shared) {
  8. self.baseURL = baseURL
  9. self.session = session
  10. }
  11. func login(request: LoginRequest, completion: @escaping (AuthResult<UserAccount>) -> Void) {
  12. // TODO: Replace stub with URLSession POST request to `/auth/login`
  13. // let endpoint = baseURL.appendingPathComponent("auth/login")
  14. // var urlReq = URLRequest(url: endpoint)
  15. // urlReq.httpMethod = "POST"
  16. // ...
  17. completion(.failure(.networkError("未配置实际远程服务器地址")))
  18. }
  19. func register(request: RegisterRequest, completion: @escaping (AuthResult<UserAccount>) -> Void) {
  20. // TODO: Replace stub with URLSession POST request to `/auth/register`
  21. completion(.failure(.networkError("未配置实际远程服务器地址")))
  22. }
  23. func updateProfile(request: UpdateProfileRequest, completion: @escaping (AuthResult<UserAccount>) -> Void) {
  24. // TODO: Replace stub with URLSession PUT request to `/user/profile`
  25. completion(.failure(.networkError("未配置实际远程服务器地址")))
  26. }
  27. func changePassword(request: ChangePasswordRequest, completion: @escaping (AuthResult<Bool>) -> Void) {
  28. // TODO: Replace stub with URLSession POST request to `/user/change-password`
  29. completion(.failure(.networkError("未配置实际远程服务器地址")))
  30. }
  31. func logout(completion: @escaping () -> Void) {
  32. // TODO: Call remote `/auth/logout` endpoint if needed
  33. completion()
  34. }
  35. func getCurrentUser() -> UserAccount? {
  36. return nil
  37. }
  38. }