Files
forkmessager/client-mobile/lib/features/auth/data/models/auth_response.dart
2026-05-14 12:06:34 +03:00

31 lines
796 B
Dart

import 'package:freezed_annotation/freezed_annotation.dart';
import '../../domain/entities/user.dart';
part 'auth_response.freezed.dart';
part 'auth_response.g.dart';
@freezed
class AuthResponse with _$AuthResponse {
const factory AuthResponse({
required String accessToken,
required String refreshToken,
required String userId,
required String username,
required String displayName,
}) = _AuthResponse;
const AuthResponse._();
factory AuthResponse.fromJson(Map<String, dynamic> json) =>
_$AuthResponseFromJson(json);
// Helper to convert to domain User
User toDomainUser() {
return User(
id: userId,
email: username, // Использование логина как email в сущности User
name: displayName,
);
}
}