import 'package:driverapp/config/config.dart';
import 'package:driverapp/core/model/hospitals/hospitals_model.dart';
import 'package:driverapp/core/model/hospitals/request_get_hospitals_model.dart';
import 'package:driverapp/core/service/base_service.dart';

class HospitalService extends BaseService {
  List<HospitalsModel> _hospitals = List();

  List<HospitalsModel> get hospitals => _hospitals;

  RequestGetHospitalsModel _requestGetHospitalsModel = RequestGetHospitalsModel(
      latitude: 0,
      longitude: 0,
      versionID: 5.2,
      channel: 3,
      languageID: 2,
      iPAdress: '10.20.10.20',
      generalid: 'Cs2020@2016\$2958',
      patientOutSA: 0,
      sessionID: 'JUWuiMBCEGkAAxQpakQ',
      isDentalAllowedBackend: false,
      deviceTypeID: 2);

  Future getHospitals() async {
    await baseAppClient.post(GET_PROJECT,
        onSuccess: (dynamic response, int statusCode) {
          _hospitals.clear();
      response['ListProject'].forEach((hospital) {
        _hospitals.add(HospitalsModel.fromJson(hospital));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: _requestGetHospitalsModel.toJson());
  }
}
