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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/perf_main/'; print('++++++++$url'); 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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/subperfinmain/?area=' + area; print('++++++++$url'); 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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/mainperfext/?perf=' + id; print('++++++++$url'); 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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/allgifuareas/?perf=' + perf; print('++++++++$url'); 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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/customareanames'; print('++++++++$url'); 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 serverUrl = ConstValues.currentServer(); String url = '$serverUrl/api/perfext/?sub_perf=' + id; print('++++++++$url'); 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; } }