import 'package:frontend_eccp_mobile/modules/auth/login/data/model/login_user.dart';

class LoginData {
  LoginData({
    required this.accessToken,
    required this.refreshToken,
    required this.tokenType,
    required this.expiresIn,
    required this.user,
  });

  factory LoginData.fromJson(Map<String, dynamic> json) {
    return LoginData(
      accessToken: json['access_token']?.toString() ?? '',
      refreshToken: json['refresh_token']?.toString() ?? '',
      tokenType: json['token_type']?.toString() ?? '',
      expiresIn: int.tryParse(json['expires_in']?.toString() ?? '0') ?? 0,
      user: LoginUser.fromJson(
        json['user'] as Map<String, dynamic>? ?? {},
      ),
    );
  }

  final String accessToken;
  final String refreshToken;
  final String tokenType;
  final int expiresIn;
  final LoginUser user;
}
