rd-android-app/lib/controller/product_mannual_service.dart
saritabirare 545637e035 1)product manual api integration
2)order management implementation
2024-09-16 16:48:52 +05:30

37 lines
1.1 KiB
Dart

import '../models/product_mannual_model.dart';
import '../utils/common_api_service.dart'; // Replace with your actual common API service import
class ProductMannualService {
Future<List<ProductManualModel>?> getProductManuals(String token) async {
try {
String url = "/api/productmanual/getall"; // Base URL to fetch product manuals
final response = await commonApiService<List<ProductManualModel>>(
method: "GET",
url: url,
additionalHeaders: { // Pass the token here
'Authorization': 'Bearer $token',
},
fromJson: (json) {
if (json['productManuals'] != null) {
// Map the list of product manuals from the response
final List<ProductManualModel> productManuals = (json['productManuals'] as List)
.map((manualJson) => ProductManualModel.fromJson(manualJson as Map<String, dynamic>))
.toList();
return productManuals;
} else {
return [];
}
},
);
return response;
} catch (e) {
print(e.toString());
return null;
}
}
}