chequemanagement #1
This commit is contained in:
@@ -105,7 +105,7 @@ class BranchService {
|
||||
if (response.statusCode == 200) {
|
||||
return Branch.listFromJson(response.data);
|
||||
} else {
|
||||
throw Exception("Failed to fetch beneficiaries");
|
||||
throw Exception("Failed to fetch");
|
||||
}
|
||||
} catch (e) {
|
||||
return [];
|
||||
|
||||
96
lib/api/services/cheque_service.dart
Normal file
96
lib/api/services/cheque_service.dart
Normal file
@@ -0,0 +1,96 @@
|
||||
import 'package:dio/dio.dart';
|
||||
class Cheque {
|
||||
final String? type;
|
||||
final String? InstrType;
|
||||
final String? Date;
|
||||
final String? branchCode;
|
||||
final String? fromCheque;
|
||||
final String? toCheque;
|
||||
final String? Chequescount;
|
||||
final String? ChequeNumber;
|
||||
final String? transactionCode;
|
||||
final String? amount;
|
||||
final String? status;
|
||||
final String? stopIssueDate;
|
||||
final String? StopExpiryDate;
|
||||
|
||||
Cheque({
|
||||
this.type,
|
||||
this.InstrType,
|
||||
this.Date,
|
||||
this.branchCode,
|
||||
this.fromCheque,
|
||||
this.toCheque,
|
||||
this.Chequescount,
|
||||
this.ChequeNumber,
|
||||
this.transactionCode,
|
||||
this.amount,
|
||||
this.status,
|
||||
this.stopIssueDate,
|
||||
this.StopExpiryDate,
|
||||
});
|
||||
|
||||
factory Cheque.fromJson(Map<String, dynamic> json) {
|
||||
return Cheque(
|
||||
type: json['type'] ?? '',
|
||||
InstrType: json['InstrType'] ?? '',
|
||||
Date: json['Date'] ?? '',
|
||||
branchCode: json['branchCode'] ?? '',
|
||||
fromCheque: json['fromCheque'] ?? '',
|
||||
toCheque: json['toCheque'] ?? '',
|
||||
Chequescount: json['Chequescount'] ?? '',
|
||||
ChequeNumber: json['ChequeNumber'] ?? '',
|
||||
transactionCode: json['transactionCode'] ?? '',
|
||||
amount: json['amount'] ?? '',
|
||||
status: json['status'] ?? '',
|
||||
stopIssueDate: json['stopIssueDate'] ?? '',
|
||||
StopExpiryDate: json['StopExpiryDate'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
static List<Cheque> listFromJson(List<dynamic> jsonList) {
|
||||
final chequeList =
|
||||
jsonList.map((cheque) => Cheque.fromJson(cheque)).toList();
|
||||
return chequeList;
|
||||
}
|
||||
}
|
||||
|
||||
class ChequeService {
|
||||
final Dio _dio;
|
||||
ChequeService(this._dio);
|
||||
|
||||
Future<List<Cheque>> ChequeEnquiry(
|
||||
{required String accountNumber,
|
||||
required String instrType,
|
||||
}) async {
|
||||
try {
|
||||
final response = await _dio.get(
|
||||
"/api/cheque",
|
||||
queryParameters: {
|
||||
'accountNumber': accountNumber,
|
||||
'instrumentType': instrType,
|
||||
},
|
||||
options: Options(
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
if (response.data is Map<String, dynamic> && response.data.containsKey('records')) {
|
||||
final records = response.data['records'];
|
||||
if (records is List) {
|
||||
return Cheque.listFromJson(records);
|
||||
}
|
||||
}
|
||||
throw Exception("Unexpected API response format: 'records' list not found or malformed");
|
||||
} else {
|
||||
throw Exception("Failed to fetch");
|
||||
}
|
||||
} catch (e) {
|
||||
print('Error in ChequeEnquiry: $e');
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user