import 'package:doctor_app_flutter/config/config.dart';
import 'package:doctor_app_flutter/config/shared_pref_kay.dart';
import 'package:doctor_app_flutter/core/model/hospitals/VidaPlusProjectListModel.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_request_model.dart';
import 'package:doctor_app_flutter/core/model/hospitals/get_hospitals_response_model.dart';
import 'package:doctor_app_flutter/core/service/base/base_service.dart';


class HospitalsService extends BaseService {
  static String memberId = "";

  List<GetHospitalsResponseModel> hospitals = [];
  List<VidaPlusProjectListModel> vidaPlusProjectListModel = [];

  Future getHospitals(GetHospitalsRequestModel getHospitalsRequestModel) async {
    memberId = getHospitalsRequestModel.memberID??"";
    hasError = false;
    await baseAppClient.post(
      GET_PROJECTS,
      onSuccess: (dynamic response, int statusCode) {
        hospitals.clear();
        response['ProjectInfo'].forEach((hospital) {
          hospitals.add(GetHospitalsResponseModel.fromJson(hospital));
        });
        vidaPlusProjectListModel.clear();
        if (response['ProjectListVidaPlus'].length != 0) {
          response['ProjectListVidaPlus'].forEach((item) {
            vidaPlusProjectListModel.add(VidaPlusProjectListModel.fromJson(item));
          });
        }
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: {"LanguageID":2,"MemberID":getHospitalsRequestModel.memberID,"DoctorID":getHospitalsRequestModel.doctorID}, //getHospitalsRequestModel.toJson(),
      isCustomRequest: true
    );
  }
}
