pd-android-app/lib/controller/get_delivered_service.dart

39 lines
1.2 KiB
Dart

import 'package:cheminova/models/get_delivered_model.dart';
import '../utils/api_urls.dart';
import '../utils/common_api_service.dart';
class GetDeliveredService {
Future<List<GetDeliveredModel>?> getRDDeliveredProduct(String token) async {
try {
String url = ApiUrls.getRdDliveredOrdergUrl; // Base URL to fetch product manuals
final response = await commonApiService<List<GetDeliveredModel>>(
method: "GET",
url: url,
additionalHeaders: { // Pass the token here
'Authorization': 'Bearer $token',
},
fromJson: (json) {
if (json['invoices'] != null) {
// If the productManuals key is present, map the response to a list of ProductManualModel objects
final List<GetDeliveredModel> productManuals = (json['invoices'] as List)
.map((manualJson) => GetDeliveredModel.fromJson(manualJson))
.toList();
return productManuals; // Return the list of product manuals
} else {
return [];
}
},
);
return response;
} catch (e) {
print("fkfgghgh ,${e.toString()}");
//print(e.toString());
return null;
}
}
}