import 'package:hmg_patient_app/config/config.dart';
import 'package:hmg_patient_app/config/shared_pref_kay.dart';
import 'package:hmg_patient_app/core/model/pharmacies/recommendedProduct_model.dart';
import 'package:hmg_patient_app/core/service/base_service.dart';
import 'package:hmg_patient_app/models/Authentication/authenticated_user.dart';
import 'package:hmg_patient_app/services/authentication/auth_provider.dart';
import 'package:hmg_patient_app/uitl/app_shared_preferences.dart';




class RecommendedProductService extends BaseService{
  AppSharedPreferences sharedPref = AppSharedPreferences();
  AppGlobal appGlobal = new AppGlobal();
  AuthenticatedUser authUser = new AuthenticatedUser();
  AuthProvider authProvider = new AuthProvider();

//  List<Map<String, dynamic>> _recommendedProductList =[];
//  List<Map<String, Object>> get recommendedList => _recommendedProductList;

  List<RecommendedProductModel> _recommendedProductList =[];
  List<RecommendedProductModel> get recommendedList => _recommendedProductList;

  Future getRecommendedProducts(productId) async {
   var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);
    hasError = false;

    await baseAppClient.getPharmacy(GET_RECOMMENDED_PRODUCT+"$productId/$customerId",
        onSuccess: (dynamic response, int statusCode) {
          _recommendedProductList.clear();
          response['products'].forEach((item) {
//            _recommendedProductList.add(item);
            _recommendedProductList.add(RecommendedProductModel.fromJson(item));

          });
          //print(item['name']);
          print(response);
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        });
  }}