supporters

This commit is contained in:
unknown
2021-09-02 01:27:59 +02:00
parent 638b8c9413
commit d72bf84a36
2 changed files with 54 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:filcnaplo/models/config.dart';
import 'package:filcnaplo/models/news.dart';
import 'package:filcnaplo/models/release.dart';
import 'package:filcnaplo/models/supporter.dart';
import 'package:filcnaplo_kreta_api/models/school.dart';
import 'package:http/http.dart' as http;
@@ -10,6 +11,7 @@ class FilcAPI {
static const SCHOOL_LIST = "https://filcnaplo.hu/v2/school_list.json";
static const CONFIG = "https://filcnaplo.hu/v2/config.json";
static const NEWS = "https://filcnaplo.hu/v2/news.json";
static const SUPPORTERS = "https://filcnaplo.hu/v2/supporters.json";
static const REPO = "filc/naplo";
static const RELEASES = "https://api.github.com/repos/$REPO/releases";
@@ -55,6 +57,20 @@ class FilcAPI {
}
}
static Future<Supporters?> getSupporters() async {
try {
http.Response res = await http.get(Uri.parse(SUPPORTERS));
if (res.statusCode == 200) {
return Supporters.fromJson(jsonDecode(res.body));
} else {
throw "HTTP ${res.statusCode}: ${res.body}";
}
} catch (error) {
print("ERROR: FilcAPI.getSupporters: $error");
}
}
static Future<List<Release>?> getReleases() async {
try {
http.Response res = await http.get(Uri.parse(RELEASES));