import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/PharmacyProduct.dart';
import 'package:diplomaticquarterapp/core/model/pharmacies/recommendedProduct_model.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/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<PharmacyProduct> _recommendedProductList = List();
  List<PharmacyProduct> get recommendedList => _recommendedProductList;
  String url ="";

  Future getRecommendedProducts(productId) async {
    hasError = false;
    url =GET_RECOMMENDED_PRODUCT+productId;
    await baseAppClient.getPharmacy(url,
        onSuccess: (dynamic response, int statusCode) {
          _recommendedProductList.clear();
          response['products'].forEach((item) {
            _recommendedProductList.add(PharmacyProduct.fromJson(item));
            print("----------------------------------");
            print("Test data");
            print(_recommendedProductList[0]);
            print(item['name']);
            print(response);
          });
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        });
  }}