import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/models/pharmacy/reviewModel.dart';
import 'package:diplomaticquarterapp/services/authentication/auth_provider.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';


class ReviewService extends BaseService {
  AppSharedPreferences sharedPref = AppSharedPreferences();

  AuthenticatedUser authUser = new AuthenticatedUser();
  AuthProvider authProvider = new AuthProvider();

  bool isLogin = false;
  List<Review> _reviewList = List();
  List<Review> get reviewList => _reviewList;


  Future getReview() async {

    var customerId = await sharedPref.getString(PHARMACY_CUSTOMER_ID);

    hasError = false;
    await baseAppClient.getPharmacy(GET_REVIEW+customerId,
        onSuccess: (dynamic response, int statusCode) {
          _reviewList.clear();
          response['reviews'].forEach((item) {
            _reviewList.add(Review.fromJson(item));
          });
        }, onFailure: (String error, int statusCode) {
          hasError = true;
          super.error = error;
        });
  }

}
