import 'package:doctor_app_flutter/config/config.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 {
 
List<GetHospitalsResponseModel> hospitals =List();

  Future getHospitals(GetHospitalsRequestModel getHospitalsRequestModel) async {
    hasError = false;
    await baseAppClient.post(
      GET_PROJECTS,
      onSuccess: (dynamic response, int statusCode) {
        hospitals.clear();
        response['ProjectInfo'].forEach((hospital) {
          hospitals.add(GetHospitalsResponseModel.fromJson(hospital));
        });
      },
      onFailure: (String error, int statusCode) {
        hasError = true;
        super.error = error;
      },
      body: getHospitalsRequestModel.toJson(),
    );
  }
}
