import 'package:auth/src/features/sign_up/domain/entities/two_fa_secret_entity.dart';
import 'package:freezed_annotation/freezed_annotation.dart';

part 'two_fa_secret_response_model.freezed.dart';
part 'two_fa_secret_response_model.g.dart';

@freezed
abstract class TwoFASecretResponseModel with _$TwoFASecretResponseModel {
  const factory TwoFASecretResponseModel({
    required bool isCreated,
    required TwoFASecretItemResponseModel item,
  }) = _TwoFASecretResponseModel;

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

@freezed
abstract class TwoFASecretItemResponseModel
    with _$TwoFASecretItemResponseModel {
  const factory TwoFASecretItemResponseModel({
    required String secret,
    required String qr,
  }) = _TwoFASecretItemResponseModel;

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

extension TwoFASecretResponseModelMapper on TwoFASecretResponseModel {
  TwoFASecretEntity toEntity() {
    return TwoFASecretEntity(
      isCreated: isCreated,
      item: TwoFASecretItemEntity(secret: item.secret, qr: item.qr),
    );
  }
}
