import 'package:cheminova/utils/api_urls.dart'; import '../models/product_mannual_model.dart'; import '../models/product_stock_model.dart'; import '../utils/common_api_service.dart'; // Replace with your actual common API service import class ProductStockService { // Method to fetch product manuals using an authorization token Future?> getProductStock(String token) async { try { String url = ApiUrls.ProductStockUrl; // Base URL to fetch product manuals final response = await commonApiService>( method: "GET", url: url, additionalHeaders: { // Pass the token here 'Authorization': 'Bearer $token', }, fromJson: (json) { if (json['stocks'] != null) { // If the productManuals key is present, map the response to a list of ProductManualModel objects final List productstock = (json['stocks'] as List) .map((manualJson) => ProductStockModel.fromJson(manualJson as Map)) .toList(); return productstock; // Return the list of product manuals } else { return []; } }, ); return response; } catch (e) { print(e.toString()); return null; } } }