enum LoginType { UserNameAndPwd, MobileNumber, } enum RegisterType { MobileNumber, Email, } class LoginRequest { final LoginType loginType; final ProcessorInfo processorInfo; final ClientInfo? clientInfo; LoginRequest({ required this.loginType, required this.processorInfo, this.clientInfo, }); Map toJson() { final map = Map(); map['LoginType'] = loginType.index; map['ProcessorInfo'] = processorInfo; if (clientInfo != null) map['ClientInfo'] = clientInfo; return map; } } class ProcessorInfo { final String? userName; final String? password; ProcessorInfo({ this.userName, this.password, }); factory ProcessorInfo.fromJson(Map map) { return ProcessorInfo( userName: map['UserName'], password: map['Password'], ); } Map toJson() { final map = Map(); if (userName != null && userName!.isNotEmpty) map['UserName'] = userName; if (password != null && password!.isNotEmpty) map['Password'] = password; return map; } } class ClientInfo { final String? clientSource; ClientInfo({ this.clientSource, }); factory ClientInfo.fromJson(Map map) { return ClientInfo( clientSource: map['ClientSource'], ); } Map toJson() { final map = Map(); if (clientSource != null && clientSource!.isNotEmpty) map['ClientSource'] = clientSource; return map; } } class LoginResult { final String userCode; final String sessionId; final String? deviceId; LoginResult({ required this.userCode, required this.sessionId, this.deviceId, }); factory LoginResult.fromJson(Map map) { return LoginResult( userCode: map['UserCode'], sessionId: map['SessionId'], deviceId: map['DeviceId'], ); } } class SignInRequest { final String userName; final String secretPassword; final String? phone; final String? email; final String? nickName; final String? fullName; final String? headImageToken; final String? lastIp; SignInRequest({ required this.userName, required this.secretPassword, this.phone, this.email, this.nickName, this.fullName, this.headImageToken, this.lastIp, }); Map toJson() { final map = Map(); map['UserName'] = userName; map['SecretPassword'] = secretPassword; if (phone != null && phone!.isNotEmpty) map['Phone'] = phone; if (email != null && email!.isNotEmpty) map['Email'] = email; if (nickName != null && nickName!.isNotEmpty) map['NickName'] = nickName; if (fullName != null && fullName!.isNotEmpty) map['FullName'] = fullName; if (headImageToken != null && headImageToken!.isNotEmpty) map['HeadImageToken'] = headImageToken; if (lastIp != null && lastIp!.isNotEmpty) map['LastIp'] = lastIp; return map; } }