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

import '../db/db_querys.dart';

class ApiDataPost{
  Future sincronizacao(urlAPI,mode,nameCityApi,map)async{
    // http://192.168.0.42:8010/api/atb/desenvolvimento/corumbatai/sincronizacao
    // print('sinc');
    // print(map);
    final url = '${urlAPI}${mode}/${nameCityApi}/sincronizacao';
    var response = await http.post(
      Uri.parse(url),
      body: jsonEncode(map),
    );
    // print(response.body);
    // print(response.statusCode);
    if(response.statusCode == 200) {
      await DBQuerys().updateCidadao();
      return json.decode(response.body);
    }else{
      return 'error';
    }
  }
}