import 'package:json_annotation/json_annotation.dart';

import 'package:pshared/api/requests/tokens/session_identifier.dart';
import 'package:pshared/data/dto/verification/purpose.dart';

part 'login.g.dart';

@JsonSerializable(explicitToJson: true)
class LoginVerificationRequest {
  final VerificationPurposeDTO purpose;
  final String? target;
  final String idempotencyKey;

  const LoginVerificationRequest({
    this.purpose = VerificationPurposeDTO.login,
    this.target,
    required this.idempotencyKey,
  });

  factory LoginVerificationRequest.fromJson(Map<String, dynamic> json) =>
      _$LoginVerificationRequestFromJson(json);
  Map<String, dynamic> toJson() => _$LoginVerificationRequestToJson(this);
}

@JsonSerializable(explicitToJson: true)
class LoginCodeVerifyicationRequest extends LoginVerificationRequest {
  final String code;
  final SessionIdentifierDTO sessionIdentifier;

  const LoginCodeVerifyicationRequest({
    super.purpose = VerificationPurposeDTO.login,
    super.target,
    required super.idempotencyKey,
    required this.code,
    required this.sessionIdentifier,
  });

  factory LoginCodeVerifyicationRequest.fromJson(Map<String, dynamic> json) =>
      _$LoginCodeVerifyicationRequestFromJson(json);
  @override
  Map<String, dynamic> toJson() => _$LoginCodeVerifyicationRequestToJson(this);
}
