Files
rog_app/lib/services/perfecture_service.dart

122 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
class PerfectureService{
static Future<List<dynamic>?> loadPerfectures() async {
List<dynamic> perfs = [];
2022-06-14 14:37:59 +05:30
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perf_main/';
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-03-24 14:20:04 +05:30
final response = await http.get(Uri.parse(url),
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 = [];
2022-06-14 14:37:59 +05:30
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/subperfinmain/?area=' + area;
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-03-30 16:19:18 +05:30
final response = await http.get(Uri.parse(url),
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 = [];
2022-06-14 14:37:59 +05:30
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/mainperfext/?perf=' + id;
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-06-06 21:15:58 +05:30
final response = await http.get(Uri.parse(url),
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 = [];
2022-06-14 14:37:59 +05:30
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/allgifuareas/?perf=' + perf;
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-06-14 14:37:59 +05:30
final response = await http.get(Uri.parse(url),
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 = [];
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/customareanames';
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-04-17 11:45:21 +05:30
final response = await http.get(Uri.parse(url),
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 = [];
2022-06-14 14:37:59 +05:30
String server_url = ConstValues.currentServer();
String url = '${server_url}/api/perfext/?sub_perf=' + id;
2023-05-16 20:40:02 +05:30
print('++++++++${url}');
2022-04-17 11:45:21 +05:30
final response = await http.get(Uri.parse(url),
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
}