LNHttpManager+Login.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // LNHttpManager+Login.swift
  3. // Lanu
  4. //
  5. // Created by OneeChan on 2025/11/11.
  6. //
  7. import Foundation
  8. private let kNetPath_Login_Google = "/user/login/google/enter"
  9. private let kNetPath_Login_Email = "/user/login/email/enter"
  10. private let kNetPath_Login_Apple = "/user/login/apple/enter"
  11. private let kNetPath_Login_Phone = "/user/login/mobile/enter"
  12. private let kNetPath_Login_Refresh = "/user/renewalToken"
  13. private let kNetPath_Logout = "/user/logout"
  14. private let kNetPath_Login_Captcha = "/user/login/mobile/sendCode"
  15. extension LNHttpManager {
  16. func loginByPhone(code: String, num: String, captcha: String,
  17. completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  18. post(path: kNetPath_Login_Phone, params: [
  19. "mobile": [
  20. "code": code,
  21. "num": num
  22. ],
  23. "code": captcha
  24. ], completion: completion)
  25. }
  26. func loginByApple(token: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  27. post(path: kNetPath_Login_Apple, params: ["data": token], completion: completion)
  28. }
  29. func loginByGoogle(token: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  30. post(path: kNetPath_Login_Google, params: ["data": token], completion: completion)
  31. }
  32. #if DEBUG
  33. func loginByEmail(email: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  34. post(path: kNetPath_Login_Email, params: ["email": email], completion: completion)
  35. }
  36. #endif
  37. func refreshToken(completion: @escaping (LNRefreshTokenResponse?, LNHttpError?) -> Void) {
  38. post(path: kNetPath_Login_Refresh, completion: completion)
  39. }
  40. func logout(completion: @escaping (LNHttpError?) -> Void) {
  41. post(path: kNetPath_Logout, completion: completion)
  42. }
  43. }
  44. extension LNHttpManager {
  45. func getLoginCaptcha(code: String, phone: String, completion: @escaping (LNHttpError?) -> Void) {
  46. post(path: kNetPath_Login_Captcha, params: [
  47. "code": code,
  48. "num": phone
  49. ], completion: completion)
  50. }
  51. }