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

class ApiDataSync{
  Future syncPerm(urlAPI,mode,nameCityApi,user)async{
    //http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/sync/perm/admin
    final url = '${urlAPI}${mode}/${nameCityApi}/sync/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);
    // print(map);
    return map;
  }
  Future syncBairros(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/bairros
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/bairros';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncTiposLogradouros(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/tiposLogradouros
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/tiposLogradouros';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncLogradouros(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/logradouros
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/logradouros';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncLoteamentos(urlAPI,mode,nameCityApi,user)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/loteamentos
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/loteamentos';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncProfissionais(urlAPI,mode,nameCityApi,user,idUnidade)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/profissionais
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/profissionais';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncProfissionaisCBOs(urlAPI,mode,nameCityApi,user,idUnidade)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/profissionaisCBOs
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/profissionaisCBOs';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncCidadaos(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cidadaos/1/1/true
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cidadaos/$area/$microarea/$foraArea';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncCadastrosDomiciliares(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cadastrosDomiciliares/1/1/true
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cadastrosDomiciliares/$area/$microarea/$foraArea';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
  Future syncCadastrosIndividuais(urlAPI,mode,nameCityApi,user,idUnidade,area,microarea,foraArea)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/admin/sync/3/cadastrosIndividuais/1/1/true
    final url = '${urlAPI}${mode}/${nameCityApi}/${user}/sync/${idUnidade}/cadastrosIndividuais/$area/$microarea/$foraArea';
    final response = await http.get(Uri.parse(url));
    final map = json.decode(response.body);
    return map;
  }
}