41 lines
1.4 KiB
Dart
41 lines
1.4 KiB
Dart
import 'package:cheminova/models/rd_processing_invoice_model.dart';
|
|
|
|
import '../utils/api_urls.dart';
|
|
import '../utils/common_api_service.dart';
|
|
|
|
class RdProcessingInvoiceService{
|
|
|
|
Future<List<InvoiceResponseModel>?> getRDProcessingProduct(String token) async {
|
|
try {
|
|
String url = ApiUrls.getRdProcessingInvoiceOrdergUrl; // Base URL to fetch product manuals
|
|
|
|
final response = await commonApiService<List<InvoiceResponseModel>>(
|
|
method: "GET",
|
|
url: url,
|
|
additionalHeaders: { // Pass the token here
|
|
'Authorization': 'Bearer $token',
|
|
},
|
|
fromJson: (json) {
|
|
// Check if the 'invoices' key is present and is a list
|
|
if (json['invoices'] != null && json['invoices'] is List) {
|
|
// Map the response to a list of InvoiceResponseModel objects
|
|
final List<InvoiceResponseModel> productManuals = (json['invoices'] as List)
|
|
.map((manualJson) => InvoiceResponseModel.fromJson(manualJson))
|
|
.toList();
|
|
return productManuals; // Return the list of product manuals
|
|
} else {
|
|
// If 'invoices' is null or not a list, return an empty list or handle it as needed
|
|
return [];
|
|
}
|
|
},
|
|
);
|
|
|
|
return response;
|
|
} catch (e) {
|
|
print("Error: ${e.toString()}");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
} |