import '../../domain/entities/mining_record.dart';

class MiningRecordModel extends MiningRecord {
  const MiningRecordModel({
    required super.id,
    required super.accountSequence,
    required super.distributionMinute,
    required super.contributionRatio,
    required super.shareAmount,
    required super.priceSnapshot,
    required super.createdAt,
  });

  factory MiningRecordModel.fromJson(Map<String, dynamic> json) {
    return MiningRecordModel(
      id: json['id'] ?? '',
      accountSequence: json['accountSequence']?.toString() ?? '',
      distributionMinute: json['distributionMinute'] ?? '',
      contributionRatio: json['contributionRatio']?.toString() ?? '0',
      shareAmount: json['shareAmount']?.toString() ?? '0',
      priceSnapshot: json['priceSnapshot']?.toString() ?? '0',
      createdAt: json['createdAt'] != null
          ? DateTime.parse(json['createdAt'])
          : DateTime.now(),
    );
  }
}
