/*
Firka legacy (formely "refilc"), the unofficial client for e-Kréta
Copyright (C) 2025 Firka team (QwIT development)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
import 'dart:async';
import 'dart:convert';
import 'dart:developer';
import 'dart:io';
import 'package:refilc/models/config.dart';
import 'package:refilc/models/news.dart';
import 'package:refilc/models/release.dart';
import 'package:refilc/models/settings.dart';
import 'package:refilc/models/shared_theme.dart';
import 'package:refilc_kreta_api/models/school.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:connectivity_plus/connectivity_plus.dart';
class FilcAPI {
// base url
static const baseUrl = "https://firka.app/api/v1";
// unused schools list
static const schoolList = "0.0.0.0";
// news endpoint
static const news = "$baseUrl/news/";
// analytics endpoint
static const config = "$baseUrl/config/";
// bug report endpoint, always gets sent, no matter if the user pressed the button or no
static const reportApi = "$baseUrl/crash/legacy";
// updates path to github
static const releases =
"https://api.github.com/repos/QwIT-Development/app-legacy/releases";
// theme sharing api
static const themeShare = "$baseUrl/theme/";
static const themeGet = "$baseUrl/theme/";
static const allThemes = "$themeGet/theme/";
static const themeByID = "$themeGet/theme/";
// i don't know why it is separated
static const gradeColorsShare = "$baseUrl/theme/color/";
static const gradeColorsGet = "$baseUrl/theme/color/";
static const allGradeColors = "$gradeColorsGet/";
static const gradeColorsByID = "$gradeColorsGet/";
static Future checkConnectivity() async =>
(await Connectivity().checkConnectivity())[0] != ConnectivityResult.none;
// nem tudom nem vazar-e senkit se, de mar ertelmetlen ez
static Future?> getSchools() async {
try {
http.Response res = await http.get(Uri.parse(schoolList));
if (res.statusCode == 200) {
List schools = (jsonDecode(res.body) as List)
.cast