part of '../auth_dtos.dart';

@freezed
class ResendDto with _$ResendDto {
  const factory ResendDto({
    @JsonKey(name: 'status') String? status,
    @JsonKey(name: 'message') String? message,
    @JsonKey(name: 'data') ResendDataDto? data,
  }) = _ResendDto;

  factory ResendDto.fromJson(Map<String, dynamic> json) =>
      _$ResendDtoFromJson(json);

  const ResendDto._();

  /// mapping ke domain
  Resend toDomain() => Resend(
    status: status?.toResendStatus() ?? ResendStatus.unknown,
    message: message ?? '',
    otpToken: data?.otpToken ?? '',
    expiresIn: data?.expiresIn ?? 0,
    nextResendIn: data?.nextResendIn ?? 0,
  );
}

@freezed
class ResendDataDto with _$ResendDataDto {
  const factory ResendDataDto({
    @JsonKey(name: 'otp_token') String? otpToken,
    @JsonKey(name: 'expires_in') int? expiresIn,
    @JsonKey(name: 'next_resend_in') int? nextResendIn,
  }) = _ResendDataDto;

  factory ResendDataDto.fromJson(Map<String, dynamic> json) =>
      _$ResendDataDtoFromJson(json);
}
