import 'dart:convert'; import 'package:http/http.dart' as http; import 'package:rogapp/utils/const.dart'; class PerfectureService{ static Future?> loadPerfectures() async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/perf_main/'; //String url = 'http://localhost:8100/api/perf_main/'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } static Future?> loadSubPerfectures(String area) async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/subperfinmain/?area=' + area; //String url = 'http://localhost:8100/api/subperfinmain/?area=' + area; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } static Future?> getMainPerfExt(String id) async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/mainperfext/?perf=' + id; //String url = 'http://localhost:8100/api/mainperfext/?perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } static Future?> loadGifuAreas(String perf) async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/allgifuareas/?perf=' + perf; //String url = 'http://localhost:8100/api/allgifuareas/?perf=' + perf; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } static Future?> loadCustomAreas() async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/customareanames'; //String url = 'http://localhost:8100/api/customareanames'; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } static Future?> getSubExt(String id) async { List perfs = []; String server_url = ConstValues.currentServer(); String url = '${server_url}/api/perfext/?sub_perf=' + id; //String url = 'http://localhost:8100/api/perfext/?sub_perf=' + id; final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json; charset=UTF-8', }, ); if (response.statusCode == 200) { perfs = json.decode(utf8.decode(response.bodyBytes)); } return perfs; } }