import '../models/withdraw_method_model.dart';

class BankWithdrawMethod extends WithdrawMethod {
  BankWithdrawMethod({
    String? withdrawMethodId,
    String? name,
    String? userId,
    this.accountNumber,
    this.accountHolderName,
    this.bankName,
    this.branchCode,
    this.swiftCode,
  }) : super(
          withdrawMethodId: withdrawMethodId,
          name: name,
          method: 'bank',
          userId: userId,
        );

  final String? accountNumber;
  final String? accountHolderName;
  final String? bankName;
  final String? branchCode;
  final String? swiftCode;

  static const String fieldAccountNumber = 'accountNumber';
  static const String fieldAccountHolderName = 'accountHolderName';
  static const String fieldBankName = 'bankName';
  static const String fieldBranchCode = 'branchCode';
  static const String fieldSwiftCode = 'swiftCode';

  factory BankWithdrawMethod.fromJson(Map<String, dynamic> json) {
    return BankWithdrawMethod(
      withdrawMethodId: json[WithdrawMethod.fieldWithdrawMethodId],
      name: json[WithdrawMethod.fieldName],
      userId: json[WithdrawMethod.fieldUserId],
      accountNumber: json[fieldAccountNumber],
      accountHolderName: json[fieldAccountHolderName],
      bankName: json[fieldBankName],
      branchCode: json[fieldBranchCode],
      swiftCode: json[fieldSwiftCode],
    );
  }

  @override
  Map<String, dynamic> toMap() {
    final map = super.toMap();
    map.addAll({
      fieldAccountNumber: accountNumber,
      fieldAccountHolderName: accountHolderName,
      fieldBankName: bankName,
      fieldBranchCode: branchCode,
      fieldSwiftCode: swiftCode,
    });
    return map;
  }
}
