// // LNHttpManager+Profile.swift // Lanu // // Created by OneeChan on 2025/11/12. // import Foundation private let kNetPath_Profile_MyInfo = "/user/my/info" private let kNetPath_Profile_EditMyInfo = "/user/my/info/edit" private let kNetPath_Profile_EditVoice = "/user/my/voiceBarApply" private let kNetPath_Profile_ResetVoice = "/user/clean/myVoiceBar" private let kNetPath_Profile_UsersInfo = "/user/get/infos" private let kNetPath_Profile_Random = "/user/info/random/profiles" private let kNetPath_Profile_Online = "/user/getUsersOnlineState" private let kNetPath_Profile_Bind_Captcha = "/user/bind/mobile/sendCode" private let kNetPath_Profile_Bind_Phone = "/user/bind/mobile" private let kNetPath_Report_Language = "/user/set/appLocaleLangSet" class LNProfileUpdateConfig { var avatar: String? var nickName: String? var gender: LNUserGender? var birthday: String? var interest: [String]? var bio: String? var photos: [String]? } extension LNHttpManager { func getMyProfileDetail(completion: @escaping (LNMyProfileResponseVO?, LNHttpError?) -> Void) { post(path: kNetPath_Profile_MyInfo, completion: completion) } func modifyMyProfile(config: LNProfileUpdateConfig, completion: @escaping (LNHttpError?) -> Void) { var params: [String: Any] = [:] if let avatar = config.avatar { params["avatar"] = avatar } if let nickname = config.nickName { params["nickname"] = nickname } if let gender = config.gender { params["gender"] = gender.rawValue } if let birthday = config.birthday { params["birthday"] = birthday } if let interest = config.interest { params["interestCateGores"] = interest } if let intro = config.bio { params["intro"] = intro } if let photos = config.photos { params["photos"] = photos } guard !params.isEmpty else { completion(nil) return } post(path: kNetPath_Profile_EditMyInfo, params: params, completion: completion) } func setMyVoiceBar(url: String, duration: Int, completion: @escaping (LNHttpError?) -> Void) { post(path: kNetPath_Profile_EditVoice, params: [ "voiceBar": url, "voiceBarDuration": duration ], completion: completion) } func cleanVoiceBar(completion: @escaping (LNHttpError?) -> Void) { post(path: kNetPath_Profile_ResetVoice, completion: completion) } } extension LNHttpManager { func getUsersInfo(uids: [String], completion: @escaping(LNUsersProfileResponse?, LNHttpError?) -> Void) { post(path: kNetPath_Profile_UsersInfo, params: [ "userNos": uids ], completion: completion) } func getRandomProfile(completion: @escaping (LNRandomProfileResponse?, LNHttpError?) -> Void) { post(path: kNetPath_Profile_Random, completion: completion) } func getUserOnlineState(uids: [String], completion: @escaping (LNUserOnlineStateResponse?, LNHttpError?) -> Void) { post(path: kNetPath_Profile_Online, params: [ "userNos": uids ], completion: completion) } } extension LNHttpManager { func getBindPhoneCaptcha(code: String, phone: String, completion: @escaping (LNHttpError?) -> Void) { post(path: kNetPath_Profile_Bind_Captcha, params: [ "code": code, "num": phone ], completion: completion) } func bindPhone(code: String, phone: String, captcha: String, completion: @escaping (LNHttpError?) -> Void) { post(path: kNetPath_Profile_Bind_Phone, params: [ "code": captcha, "mobile": [ "code": code, "num": phone ] ], completion: completion) } } extension LNHttpManager { func reportCurrentLanguage(code: String, completion: @escaping (LNHttpError?) -> Void) { post(path: kNetPath_Report_Language, params: [ "langCode": code ], completion: completion) } }