Test APK with cheque
This commit is contained in:
138
lib/api/services/cheque_service.dart
Normal file
138
lib/api/services/cheque_service.dart
Normal file
@@ -0,0 +1,138 @@
|
||||
import 'dart:convert';
|
||||
|
||||
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 int? 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/enquiry",
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Future stopCheque({
|
||||
required String accountno,
|
||||
required String stopFromChequeNo,
|
||||
required String instrType,
|
||||
String? stopToChequeNo,
|
||||
String? stopIssueDate,
|
||||
String? stopExpiryDate,
|
||||
String? stopAmount,
|
||||
String? stopComment,
|
||||
String? chequeIssueDate,
|
||||
required String tpin,
|
||||
}) async {
|
||||
final response = await _dio.post(
|
||||
'/api/cheque/stop',
|
||||
options: Options(
|
||||
validateStatus: (int? status) => true,
|
||||
receiveDataWhenStatusError: true,
|
||||
),
|
||||
data: {
|
||||
'accountNumber': accountno,
|
||||
'stopFromChequeNo': stopFromChequeNo,
|
||||
'instrumentType': instrType,
|
||||
'stopToChequeNo': stopToChequeNo,
|
||||
'stopIssueDate': stopIssueDate,
|
||||
'stopExpiryDate': stopExpiryDate,
|
||||
'stopAmount': stopAmount,
|
||||
'stopComment': stopComment,
|
||||
'chqIssueDate': chequeIssueDate,
|
||||
'tpin': tpin,
|
||||
},
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception(jsonEncode(response.data));
|
||||
}
|
||||
return response.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user