class Beneficiary { final String accountNo; final String accountType; final String name; final String ifscCode; final String? bankName; final String? branchName; final String? tpin; Beneficiary({ required this.accountNo, required this.accountType, required this.name, required this.ifscCode, this.bankName, this.branchName, this.tpin, }); factory Beneficiary.fromJson(Map json) { return Beneficiary( accountNo: json['account_no'] ?? json['accountNo'] ?? '', accountType: json['account_type'] ?? json['accountType'] ?? '', name: json['name'] ?? '', ifscCode: json['ifsc_code'] ?? json['ifscCode'] ?? '', bankName: json['bank_name'] ?? json['bankName'] ?? '', branchName: json['branch_name'] ?? json['branchName'] ?? '', ); } Map toJson() { final Map json = { 'accountNo': accountNo, 'accountType': accountType, 'name': name, 'ifscCode': ifscCode, }; if (bankName != null && bankName!.isNotEmpty) { json['bankName'] = bankName; } if (branchName != null && branchName!.isNotEmpty) { json['branchName'] = branchName; } if (tpin != null && tpin!.isNotEmpty) { json['tpin'] = tpin; } return json; } static List listFromJson(List jsonList) { final beneficiaryList = jsonList .map((beneficiary) => Beneficiary.fromJson(beneficiary)) .toList(); return beneficiaryList; } @override String toString() { return 'Beneficiary(accountNo: $accountNo, accountType: $accountType, ifscCode: $ifscCode, name: $name)'; } }