part of '../auth_dtos.dart';

@freezed
class RegisterDto with _$RegisterDto {
  const RegisterDto._();

  const factory RegisterDto({
    @JsonKey(name: 'status') String? status,
    @JsonKey(name: 'message') String? message,
    @JsonKey(name: 'data') RegisterDataDto? data,
  }) = _RegisterDto;

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

  /// mapping ke domain
  Register toDomain() => Register(
    status: status ?? '',
    message: message ?? '',
    registrationToken: data?.registrationToken ?? '',
    otpToken: data?.otpToken ?? '',
    expiresIn: data?.expiresIn ?? 0,
  );
}

@freezed
class RegisterDataDto with _$RegisterDataDto {
  const factory RegisterDataDto({
    @JsonKey(name: 'registration_token') String? registrationToken,
    @JsonKey(name: 'otp_token') String? otpToken,
    @JsonKey(name: 'expires_in') int? expiresIn,
  }) = _RegisterDataDto;

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