import 'package:pshared/api/responses/login_pending.dart';
import 'package:pshared/api/responses/token.dart';
import 'package:pshared/data/mapper/account/account.dart';
import 'package:pshared/models/account/account.dart';
import 'package:pshared/models/session_identifier.dart';


class PendingLogin {
  final Account account;
  final TokenData pendingToken;
  final String destination;
  final int ttlSeconds;
  final SessionIdentifier session;

  const PendingLogin({
    required this.account,
    required this.pendingToken,
    required this.destination,
    required this.ttlSeconds,
    required this.session,
  });

  factory PendingLogin.fromResponse(
    PendingLoginResponse response, {
    required SessionIdentifier session,
  }) => PendingLogin(
    account: response.account.account.toDomain(),
    pendingToken: response.pendingToken,
    destination: response.destination,
    ttlSeconds: response.ttlSeconds,
    session: session,
  );
}
