Files
rog_app/lib/services/perfecture_service.dart

114 lines
3.2 KiB
Dart
Raw Normal View History

2022-03-24 14:20:04 +05:30
import 'dart:convert';
import 'package:http/http.dart' as http;
2022-06-14 14:37:59 +05:30
import 'package:rogapp/utils/const.dart';
2022-03-24 14:20:04 +05:30
2023-10-06 16:25:21 +05:30
class PerfectureService {
2022-03-24 14:20:04 +05:30
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/perf_main/';
2023-10-06 16:25:21 +05:30
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-03-24 14:20:04 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
2022-03-30 16:19:18 +05:30
perfs = json.decode(utf8.decode(response.bodyBytes));
2022-03-24 14:20:04 +05:30
}
return perfs;
}
2022-06-06 21:15:58 +05:30
static Future<List<dynamic>?> loadSubPerfectures(String area) async {
2022-03-30 16:19:18 +05:30
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
2023-10-06 16:25:21 +05:30
String url = '$serverUrl/api/subperfinmain/?area=$area';
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-03-30 16:19:18 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
2022-04-17 11:45:21 +05:30
static Future<List<dynamic>?> getMainPerfExt(String id) async {
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
2023-10-06 16:25:21 +05:30
String url = '$serverUrl/api/mainperfext/?perf=$id';
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-06-06 21:15:58 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
static Future<List<dynamic>?> loadGifuAreas(String perf) async {
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
2023-10-06 16:25:21 +05:30
String url = '$serverUrl/api/allgifuareas/?perf=$perf';
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-06-14 14:37:59 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
static Future<List<dynamic>?> loadCustomAreas() async {
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
String url = '$serverUrl/api/customareanames';
2023-10-06 16:25:21 +05:30
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-04-17 11:45:21 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
static Future<List<dynamic>?> getSubExt(String id) async {
List<dynamic> perfs = [];
2023-08-16 14:53:32 +05:30
String serverUrl = ConstValues.currentServer();
2023-10-06 16:25:21 +05:30
String url = '$serverUrl/api/perfext/?sub_perf=$id';
//print('++++++++$url');
final response = await http.get(
Uri.parse(url),
2022-04-17 11:45:21 +05:30
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
if (response.statusCode == 200) {
perfs = json.decode(utf8.decode(response.bodyBytes));
}
return perfs;
}
2022-03-24 14:20:04 +05:30
}