class LoginResponse { const LoginResponse({ required this.success, this.accessToken, this.refreshToken, this.idToken, this.tokenType, this.expiresIn, this.username, this.roles = const [], this.message, }); factory LoginResponse.fromJson(Map json) { return LoginResponse( success: json['success'] == true, accessToken: json['accessToken'] as String?, refreshToken: json['refreshToken'] as String?, idToken: json['idToken'] as String?, tokenType: json['tokenType'] as String?, expiresIn: (json['expiresIn'] as num?)?.toInt(), username: json['username'] as String?, roles: (json['roles'] as List?) ?.map((role) => role.toString()) .toList() ?? const [], message: json['message'] as String?, ); } final bool success; final String? accessToken; final String? refreshToken; final String? idToken; final String? tokenType; final int? expiresIn; final String? username; final List roles; final String? message; LoginResponse copyWith({ bool? success, String? accessToken, String? refreshToken, String? idToken, String? tokenType, int? expiresIn, String? username, List? roles, String? message, }) { return LoginResponse( success: success ?? this.success, accessToken: accessToken ?? this.accessToken, refreshToken: refreshToken ?? this.refreshToken, idToken: idToken ?? this.idToken, tokenType: tokenType ?? this.tokenType, expiresIn: expiresIn ?? this.expiresIn, username: username ?? this.username, roles: roles ?? this.roles, message: message ?? this.message, ); } }