import 'dart:convert';
import 'package:http/http.dart' as http;

class ApiDataLoad{
  Future apiConect(urlAPI,mode,nameCityApi,user)async{
    //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/pass/admin
    //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/pass/admin
    final url = '${urlAPI}${mode}/${nameCityApi}/pass/${user}';
    print(url);
    final response = await http.get(Uri.parse(url));
    var map;
    print(response.statusCode);
    if(response.statusCode == 200){
      return map = json.decode(response.body);
    }else{
      return map = 'Erro';
    }
  }
  Future loadPerm(urlAPI,mode,nameCityApi,user)async{
    //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/load/perm/admin
    //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/load/perm/admin
    final url = '${urlAPI}${mode}/${nameCityApi}/load/perm/${user}';
    // final url = 'http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/load/perm/admin';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadUnidades(urlAPI,mode,nameCityApi,user)async{
    //https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/admin/load/unidades
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/unidades
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/unidades';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadProcedimentos(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentos
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentos';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadProcedimentosRegistros(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosRegistros
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosRegistros';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadCID(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/cid
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/cid';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadProcedimentosCID(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosCID
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosCID';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadCBO(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/cbo
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/cbo';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadProcedimentosCBO(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/procedimentosCBO
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/procedimentosCBO';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadCIAP(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/ciap
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/ciap';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadMunicipios(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/municipios
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/municipios';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadEquipes(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/equipes
    // https://app0.rkmsistemas.com.br/api/atb/homologacao/cabreuva/admin/load/equipes
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/equipes';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadEquipeComponentes(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/equipeComponentes
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/equipeComponentes';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future loadCompetencia(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/load/competencia
    'criar uma lista dentro do DB não usar essa api para competencia';
    'competencia sera dinamica com 4 meses para tras exemplo 042023/032023/022023/01/2023';
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/load/competencia';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
}