LNHttpManager+Account.swift 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // LNHttpManager+Account.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. private let kNetPath_Online_Heartbeat = "/user/online/heartbeat"
  16. extension LNHttpManager {
  17. func loginByPhone(code: String, num: String, captcha: String,
  18. completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  19. post(path: kNetPath_Login_Phone, params: [
  20. "mobile": [
  21. "code": code,
  22. "num": num
  23. ],
  24. "code": captcha
  25. ], completion: completion)
  26. }
  27. func loginByApple(token: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  28. post(path: kNetPath_Login_Apple, params: ["data": token], completion: completion)
  29. }
  30. func loginByGoogle(token: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  31. post(path: kNetPath_Login_Google, params: ["data": token], completion: completion)
  32. }
  33. #if DEBUG
  34. func loginByEmail(email: String, completion: @escaping (LNLoginResponse?, LNHttpError?) -> Void) {
  35. post(path: kNetPath_Login_Email, params: ["email": email], completion: completion)
  36. }
  37. #endif
  38. func refreshToken(completion: @escaping (LNRefreshTokenResponse?, LNHttpError?) -> Void) {
  39. post(path: kNetPath_Login_Refresh, completion: completion)
  40. }
  41. func logout(completion: @escaping (LNHttpError?) -> Void) {
  42. post(path: kNetPath_Logout, completion: completion)
  43. }
  44. func reportOnlineHeartbeat(completion: @escaping (LNHttpError?) -> Void) {
  45. post(path: kNetPath_Online_Heartbeat, completion: completion)
  46. }
  47. }
  48. extension LNHttpManager {
  49. func getLoginCaptcha(code: String, phone: String, completion: @escaping (LNHttpError?) -> Void) {
  50. post(path: kNetPath_Login_Captcha, params: [
  51. "code": code,
  52. "num": phone
  53. ], completion: completion)
  54. }
  55. }