diff --git a/firka/lib/api/client/kreta_client.dart b/firka/lib/api/client/kreta_client.dart index 87ee784..6b3435d 100644 --- a/firka/lib/api/client/kreta_client.dart +++ b/firka/lib/api/client/kreta_client.dart @@ -3,14 +3,11 @@ import 'dart:convert'; import 'dart:math'; import 'package:dio/dio.dart'; -import 'package:firka/api/model/all_lessons.dart'; -import 'package:firka/api/model/class_group.dart'; -import 'package:firka/api/model/homework.dart'; -import 'package:firka/api/model/timetable.dart'; import 'package:firka/data/models/generic_cache_model.dart'; import 'package:firka/data/models/timetable_cache_model.dart'; import 'package:intl/intl.dart'; import 'package:isar_community/isar.dart'; +import 'package:kreta_api/kreta_api.dart' hide KretaEndpoints; import 'package:firka/app/app_state.dart'; import 'package:firka/core/bloc/reauth_cubit.dart'; @@ -20,12 +17,6 @@ import 'package:firka/core/debug_helper.dart'; import 'package:firka/services/active_account_helper.dart'; import 'package:firka/services/watch_sync_helper.dart'; import '../consts.dart'; -import '../exceptions/token.dart'; -import '../model/grade.dart'; -import '../model/notice_board.dart'; -import '../model/omission.dart'; -import '../model/student.dart'; -import '../model/test.dart'; import '../token_grant.dart'; import 'dart:io'; @@ -38,25 +29,6 @@ const backoffCount = 4; const backoffMin = 100; const backoffStep = 500; -class ApiResponse { - T? response; - int statusCode; - String? err; - bool cached; - - ApiResponse(this.response, this.statusCode, this.err, this.cached); - - @override - String toString() { - return "ApiResponse(" - "response: $response, " - "statusCode: $statusCode, " - "err: \"$err\", " - "cached: $cached" - ")"; - } -} - class KretaClient { Completer? _tokenMutexCompleter; TokenModel model; diff --git a/firka/lib/api/client/kreta_stream.dart b/firka/lib/api/client/kreta_stream.dart index d73cef6..ff539fa 100644 --- a/firka/lib/api/client/kreta_stream.dart +++ b/firka/lib/api/client/kreta_stream.dart @@ -1,12 +1,5 @@ -import 'package:firka/api/model/class_group.dart'; -import 'package:firka/api/model/homework.dart'; -import 'package:firka/api/model/notice_board.dart'; -import 'package:firka/api/model/omission.dart'; -import 'package:firka/api/model/test.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; -import '../model/grade.dart'; -import '../model/student.dart'; import 'kreta_client.dart'; bool getStudentFL = false; diff --git a/firka/lib/api/client/live_activity_backend_client.dart b/firka/lib/api/client/live_activity_backend_client.dart index adcacc4..22ce658 100644 --- a/firka/lib/api/client/live_activity_backend_client.dart +++ b/firka/lib/api/client/live_activity_backend_client.dart @@ -1,5 +1,5 @@ import 'package:dio/dio.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:logging/logging.dart'; import 'package:flutter_dotenv/flutter_dotenv.dart'; diff --git a/firka/lib/api/consts.dart b/firka/lib/api/consts.dart index 42dea13..23d5b62 100644 --- a/firka/lib/api/consts.dart +++ b/firka/lib/api/consts.dart @@ -5,6 +5,7 @@ import 'dart:typed_data'; import 'package:crypto/crypto.dart'; import 'package:firka/app/app_state.dart'; +import 'package:kreta_api/kreta_api.dart' as ka; class Constants { static String get clientId { @@ -41,8 +42,6 @@ class TimetableConsts { } class KretaEndpoints { - static String kretaBase = "e-kreta.hu"; - static String _generateCodeVerifier() { var random = Random.secure(); final bytes = List.generate(32, (i) => random.nextInt(256)); @@ -64,13 +63,7 @@ class KretaEndpoints { return base64Url.encode(bytes).replaceAll('=', ''); } - static String kreta(String iss) { - if (iss == "firka-test") { - return kretaBase; - } else { - return "https://$iss.$kretaBase"; - } - } + static String kreta(String iss) => ka.KretaEndpoints.kreta(iss); static final String codeVerifier = _generateCodeVerifier(); static final String _codeChallenge = _generateCodeChallenge(codeVerifier); @@ -86,38 +79,28 @@ class KretaEndpoints { static String tokenGrantUrl = "$kretaIdp/connect/token"; static String getStudentUrl(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/TanuloAdatlap"; + ka.KretaEndpoints.getStudentUrl(iss); static String getClassGroups(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/OsztalyCsoportok"; + ka.KretaEndpoints.getClassGroups(iss); static String getNoticeBoard(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/FaliujsagElemek"; + ka.KretaEndpoints.getNoticeBoard(iss); - // for some reason the [redacted] devs decided to make - // two different apis to get items for the notice board - // that appears on the home screen, like wtf - static String getInfoBoard(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/Feljegyzesek"; + static String getInfoBoard(String iss) => ka.KretaEndpoints.getInfoBoard(iss); - static String getGrades(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/Ertekelesek"; + static String getGrades(String iss) => ka.KretaEndpoints.getGrades(iss); static String getSubjectAvg(String iss, String studyGroupId) => - "${kreta(iss)}/ellenorzo/v3/sajat/Ertekelesek/Atlagok/TantargyiAtlagok?oktatasiNevelesiFeladatUid=$studyGroupId&oktatasiNevelesiFeladatUid=$studyGroupId"; + ka.KretaEndpoints.getSubjectAvg(iss, studyGroupId); - static String getTimeTable(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/OrarendElemek"; + static String getTimeTable(String iss) => ka.KretaEndpoints.getTimeTable(iss); - static String getOmissions(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/Mulasztasok"; + static String getOmissions(String iss) => ka.KretaEndpoints.getOmissions(iss); - static String getHomework(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/HaziFeladatok"; + static String getHomework(String iss) => ka.KretaEndpoints.getHomework(iss); - static String getTests(String iss) => - "${kreta(iss)}/ellenorzo/v3/sajat/BejelentettSzamonkeresek"; + static String getTests(String iss) => ka.KretaEndpoints.getTests(iss); - static String getLessons(String iss) => - "${kreta(iss)}/dktapi/intezmenyek/munkaterek/tanulok"; + static String getLessons(String iss) => ka.KretaEndpoints.getLessons(iss); } diff --git a/firka/lib/api/exceptions/token.dart b/firka/lib/api/exceptions/token.dart deleted file mode 100644 index 70ccdbb..0000000 --- a/firka/lib/api/exceptions/token.dart +++ /dev/null @@ -1,7 +0,0 @@ -class TokenExpiredException implements Exception { - TokenExpiredException(); -} - -class InvalidGrantException implements Exception { - InvalidGrantException(); -} diff --git a/firka/lib/api/model/all_lessons.dart b/firka/lib/api/model/all_lessons.dart deleted file mode 100644 index c09b44d..0000000 --- a/firka/lib/api/model/all_lessons.dart +++ /dev/null @@ -1,131 +0,0 @@ -import 'dart:convert'; - -class AllLessons { - final String schoolId; - final String yearId; - final dynamic classId; - final String? className; - final bool classWorkspace; - final dynamic groupId; - final String? groupName; - final bool groupWorkspace; - final String groupWorkspaceName; - final dynamic subjectId; - final String subjectName; - final dynamic teacherId; - final String teacherGuid; - final String teacherName; - final dynamic teacherAnnoId; - final dynamic annoId; - final String? languageId; - final dynamic subjectCategoryId; - final String subjectCategoryName; - final dynamic typeId; - final String typeName; - final dynamic gradeTypeId; - final String gradeTypeName; - final dynamic taskPlaceId; - final String taskPlaceName; - final dynamic teacherAvatarTypeId; - final String teacherAvatarTypePath; - final dynamic taskGroupId; - - AllLessons({ - required this.schoolId, - required this.yearId, - this.classId, - this.className, - required this.classWorkspace, - this.groupId, - this.groupName, - required this.groupWorkspace, - required this.groupWorkspaceName, - required this.subjectId, - required this.subjectName, - required this.teacherId, - required this.teacherGuid, - required this.teacherName, - this.teacherAnnoId, - this.annoId, - this.languageId, - required this.subjectCategoryId, - required this.subjectCategoryName, - required this.typeId, - required this.typeName, - required this.gradeTypeId, - required this.gradeTypeName, - required this.taskPlaceId, - required this.taskPlaceName, - required this.teacherAvatarTypeId, - required this.teacherAvatarTypePath, - this.taskGroupId, - }); - - factory AllLessons.fromJson(Map json) => AllLessons( - schoolId: json['intezmenyId']?.toString() ?? '', - yearId: json['tanevId']?.toString() ?? '', - classId: json['osztalyId'], - className: json['osztalyNev']?.toString(), - classWorkspace: json['osztalyMunkaTer'] == true, - groupId: json['csoportId'], - groupName: json['csoportNev']?.toString(), - groupWorkspace: json['csoportMunkaTer'] == true, - groupWorkspaceName: json['osztalyCsoportNev']?.toString() ?? '', - subjectId: json['tantargyId'], - subjectName: json['tantargyNev']?.toString() ?? '', - teacherId: json['alkalmazottId'], - teacherGuid: json['alkalmazottGuid']?.toString() ?? '', - teacherName: json['alkalmazottNev']?.toString() ?? '', - teacherAnnoId: json['alkalmazottUzenoFalId'], - annoId: json['uzenoFalId'], - languageId: json['nyelvId']?.toString(), - subjectCategoryId: json['tantargyKategoriaId'], - subjectCategoryName: json['tantargyKategoriaNev']?.toString() ?? '', - typeId: json['tipusId'], - typeName: json['tipusNev']?.toString() ?? '', - gradeTypeId: json['evfolyamTipusId'], - gradeTypeName: json['evfolyamTipusNev']?.toString() ?? '', - taskPlaceId: json['feladatEllatasiHelyId'], - taskPlaceName: json['feladatEllatasiHelyNev']?.toString() ?? '', - teacherAvatarTypeId: json['alkalmazottAvatarTipusId'], - teacherAvatarTypePath: json['alkalmazottAvatarEleres']?.toString() ?? '', - taskGroupId: json['oraiFeladatGroupId'], - ); - - Map toJson() => { - 'intezmenyId': schoolId, - 'tanevId': yearId, - 'osztalyId': classId, - 'osztalyNev': className, - 'osztalyMunkaTer': classWorkspace, - 'csoportId': groupId, - 'csoportNev': groupName, - 'csoportMunkaTer': groupWorkspace, - 'osztalyCsoportNev': groupWorkspaceName, - 'tantargyId': subjectId, - 'tantargyNev': subjectName, - 'alkalmazottId': teacherId, - 'alkalmazottGuid': teacherGuid, - 'alkalmazottNev': teacherName, - 'alkalmazottUzenoFalId': teacherAnnoId, - 'uzenoFalId': annoId, - 'nyelvId': languageId, - 'tantargyKategoriaId': subjectCategoryId, - 'tantargyKategoriaNev': subjectCategoryName, - 'tipusId': typeId, - 'tipusNev': typeName, - 'evfolyamTipusId': gradeTypeId, - 'evfolyamTipusNev': gradeTypeName, - 'feladatEllatasiHelyId': taskPlaceId, - 'feladatEllatasiHelyNev': taskPlaceName, - 'alkalmazottAvatarTipusId': teacherAvatarTypeId, - 'alkalmazottAvatarEleres': teacherAvatarTypePath, - 'oraiFeladatGroupId': taskGroupId, - }; -} - -List lessonsFromJson(String str) => - List.from(json.decode(str).map((x) => AllLessons.fromJson(x))); - -String lessonsToJson(List data) => - json.encode(List.from(data.map((x) => x.toJson()))); diff --git a/firka/lib/api/model/class_group.dart b/firka/lib/api/model/class_group.dart deleted file mode 100644 index f2cc43f..0000000 --- a/firka/lib/api/model/class_group.dart +++ /dev/null @@ -1,113 +0,0 @@ -import 'package:firka/api/model/generic.dart'; - -class ClassGroup { - final String uid; - final String name; - final UidObj? headTeacher; - final UidObj? substituteHeadTeacher; - final NameUidDesc studyGroup; - final int? studyGroupSortIndex; - final NameUidDesc? studyTask; - final bool isActive; - final String type; - - ClassGroup({ - required this.uid, - required this.name, - required this.headTeacher, - required this.substituteHeadTeacher, - required this.studyGroup, - required this.studyGroupSortIndex, - required this.studyTask, - required this.isActive, - required this.type, - }); - - factory ClassGroup.fromJson(Map json) { - return ClassGroup( - uid: json['Uid'], - name: json['Nev'], - headTeacher: json['OsztalyFonok'] != null - ? UidObj.fromJson(json['OsztalyFonok']) - : null, - substituteHeadTeacher: json['OsztalyFonokHelyettes'] != null - ? UidObj.fromJson(json['OsztalyFonokHelyettes']) - : null, - studyGroup: NameUidDesc.fromJson(json['OktatasNevelesiKategoria']), - studyGroupSortIndex: json['OktatasNevelesiKategoriaSortIndex'], - studyTask: json['OktatasNevelesiFeladat'] != null - ? NameUidDesc.fromJson(json['OktatasNevelesiFeladat']) - : null, - isActive: json['IsAktiv'], - type: json['Tipus'], - ); - } - - @override - String toString() { - return 'ClassGroup(' - 'uid: "$uid", ' - 'name: "$name", ' - 'headTeacher: $headTeacher, ' - 'substituteHeadTeacher: $substituteHeadTeacher, ' - 'studyGroup: $studyGroup, ' - 'studyGroupSortIndex: $studyGroupSortIndex, ' - 'studyTask: $studyTask, ' - 'isActive: $isActive, ' - 'type: "$type"' - ')'; - } -} - -class SubjectAverage { - final String uid; - final String name; - final String? teacherName; - final String subjectCategoryId; - final String subjectCategoryName; - final String subjectCategoryDescription; - final double? average; - final double? weightedSum; - final double? weightedCount; - final int sortIndex; - - SubjectAverage({ - required this.uid, - required this.name, - this.teacherName, - required this.subjectCategoryId, - required this.subjectCategoryName, - required this.subjectCategoryDescription, - this.average, - this.weightedSum, - this.weightedCount, - required this.sortIndex, - }); - - factory SubjectAverage.fromJson(Map json) { - final tantargy = json['Tantargy'] ?? {}; - final kategori = tantargy['Kategoria'] ?? {}; - - return SubjectAverage( - uid: json['Uid'] ?? '', - name: tantargy['Nev'] ?? '', - teacherName: json['TeacherName'], - subjectCategoryId: kategori['Uid'] ?? '', - subjectCategoryName: kategori['Nev'] ?? '', - subjectCategoryDescription: kategori['Leiras'] ?? '', - average: json['Atlag'] != null ? (json['Atlag'] as num).toDouble() : null, - weightedSum: json['SulyozottOsztalyzatOsszege'] != null - ? (json['SulyozottOsztalyzatOsszege'] as num).toDouble() - : null, - weightedCount: json['SulyozottOsztalyzatSzama'] != null - ? (json['SulyozottOsztalyzatSzama'] as num).toDouble() - : null, - sortIndex: tantargy['SortIndex'] ?? 0, - ); - } - - @override - String toString() { - return 'SubjectAverage(uid: "$uid", name: "$name", category: "$subjectCategoryName", average: $average)'; - } -} diff --git a/firka/lib/api/model/generic.dart b/firka/lib/api/model/generic.dart deleted file mode 100644 index cb2d276..0000000 --- a/firka/lib/api/model/generic.dart +++ /dev/null @@ -1,64 +0,0 @@ -class NameUidDesc { - final String uid; - final String? name; - final String? description; - - NameUidDesc({ - required this.uid, - required this.name, - required this.description, - }); - - factory NameUidDesc.fromJson(Map json) { - return NameUidDesc( - uid: json['Uid'], - name: json['Nev'], - description: json['Leiras'], - ); - } - - Map toJson() { - return {'Uid': uid, 'Nev': name, 'Leiras': description}; - } - - @override - String toString() { - return 'NameUidDesc(' - 'uid: "$uid", ' - 'name: "$name", ' - 'description: "$description"' - ')'; - } -} - -class NameUid { - final String uid; - final String name; - - NameUid({required this.uid, required this.name}); - - factory NameUid.fromJson(Map json) { - return NameUid(uid: json['Uid'], name: json['Nev']); - } - - Map toJson() { - return {'Uid': uid, 'Nev': name}; - } -} - -class UidObj { - final String uid; - - UidObj({required this.uid}); - - factory UidObj.fromJson(Map json) { - return UidObj(uid: json['Uid']); - } - - @override - String toString() { - return 'UidObj(' - 'uid: "$uid"' - ')'; - } -} diff --git a/firka/lib/api/model/grade.dart b/firka/lib/api/model/grade.dart deleted file mode 100644 index 2c293c4..0000000 --- a/firka/lib/api/model/grade.dart +++ /dev/null @@ -1,113 +0,0 @@ -import 'package:firka/api/model/generic.dart'; -import 'package:firka/api/model/subject.dart'; - -class Grade { - final String uid; - final DateTime recordDate; - final DateTime creationDate; - final DateTime? ackDate; - final Subject subject; - final String? topic; - final NameUidDesc type; - final NameUidDesc? mode; - NameUidDesc valueType; - final String teacher; - final String? kind; - int? numericValue; - final String strValue; - final int? weightPercentage; - final String? shortStrValue; - final UidObj? classGroup; - final int sortIndex; - - Grade({ - required this.uid, - required this.recordDate, - required this.creationDate, - this.ackDate, - required this.subject, - this.topic, - required this.type, - this.mode, - required this.valueType, - required this.teacher, - this.kind, - this.numericValue, - required this.strValue, - this.weightPercentage, - this.shortStrValue, - this.classGroup, - required this.sortIndex, - }); - - factory Grade.fromJson(Map json) { - return Grade( - uid: json['Uid'], - recordDate: DateTime.parse(json['RogzitesDatuma']).toLocal(), - creationDate: DateTime.parse(json['KeszitesDatuma']).toLocal(), - ackDate: json['LattamozasDatuma'] != null - ? DateTime.parse(json['LattamozasDatuma']).toLocal() - : null, - subject: Subject.fromJson(json['Tantargy']), - topic: json['Tema'], - type: NameUidDesc.fromJson(json['Tipus']), - mode: json['Mod'] != null ? NameUidDesc.fromJson(json['Mod']) : null, - valueType: NameUidDesc.fromJson(json['ErtekFajta']), - teacher: json['ErtekeloTanarNeve'], - kind: json['Kind'], - numericValue: json['SzamErtek'], - strValue: json['SzovegesErtek'], - weightPercentage: json['SulySzazalekErteke'], - shortStrValue: json['SzovegesErtekelesRovidNev'], - classGroup: json['OsztalyCsoport'] != null - ? UidObj.fromJson(json['OsztalyCsoport']) - : null, - sortIndex: json['SortIndex'], - ); - } - - Map toJson() { - return { - 'Uid': uid, - 'RogzitesDatuma': recordDate.toUtc().toIso8601String(), - 'KeszitesDatuma': creationDate.toUtc().toIso8601String(), - 'LattamozasDatuma': ackDate?.toUtc().toIso8601String(), - 'Tantargy': subject.toJson(), - 'Tema': topic, - 'Tipus': type.toJson(), - 'Mod': mode?.toJson(), - 'ErtekFajta': valueType.toJson(), - 'ErtekeloTanarNeve': teacher, - 'Kind': kind, - 'SzamErtek': numericValue, - 'SzovegesErtek': strValue, - 'SulySzazalekErteke': weightPercentage, - 'SzovegesErtekelesRovidNev': shortStrValue, - 'OsztalyCsoport': classGroup != null ? {'Uid': classGroup!.uid} : null, - 'SortIndex': sortIndex, - }; - } - - @override - String toString() { - return 'Grade(' - 'uid: "$uid", ' - 'recordDate: "$recordDate", ' - 'creationDate: "$creationDate", ' - 'ackDate: "${ackDate ?? 'null'}", ' - 'subject: $subject, ' - 'topic: "${topic ?? 'null'}", ' - 'type: $type, ' - 'mode: ${mode ?? 'null'}, ' - 'valueType: $valueType, ' - 'teacher: "$teacher", ' - 'kind: "${kind ?? 'null'}", ' - 'numericValue: ${numericValue ?? 'null'}, ' - 'strValue: "$strValue", ' - 'weightPercentage: ${weightPercentage ?? 'null'}, ' - 'shortStrValue: "${shortStrValue ?? 'null'}", ' - 'classGroup: ${classGroup ?? 'null'}, ' - 'sortIndex: $sortIndex' - ')'; - } -} diff --git a/firka/lib/api/model/guardian.dart b/firka/lib/api/model/guardian.dart deleted file mode 100644 index 123bf4f..0000000 --- a/firka/lib/api/model/guardian.dart +++ /dev/null @@ -1,36 +0,0 @@ -class Guardian { - final String? email; - final bool isLegalRepresentative; - final String? name; - final String? phoneNumber; - final String uid; - - Guardian({ - required this.email, - required this.isLegalRepresentative, - required this.name, - required this.phoneNumber, - required this.uid, - }); - - factory Guardian.fromJson(Map json) { - return Guardian( - email: json['EmailCim'], - isLegalRepresentative: json['IsTorvenyesKepviselo'], - name: json['Nev'], - phoneNumber: json['Telefonszam'], - uid: json['Uid'], - ); - } - - @override - String toString() { - return 'Guardian(' - 'email: "$email", ' - 'isLegalRepresentative: $isLegalRepresentative, ' - 'name: "$name", ' - 'phoneNumber: "$phoneNumber", ' - 'uid: "$uid"' - ')'; - } -} diff --git a/firka/lib/api/model/homework.dart b/firka/lib/api/model/homework.dart deleted file mode 100644 index 0bb89fa..0000000 --- a/firka/lib/api/model/homework.dart +++ /dev/null @@ -1,72 +0,0 @@ -import 'package:firka/api/model/subject.dart'; - -import 'generic.dart'; - -class Homework { - final String uid; - final Subject subject; - final String subjectName; - final String teacherName; - final String description; - final DateTime startDate; - final DateTime dueDate; - final DateTime creationDate; - final bool isCreatedByTeacher; - final bool isDone; - final bool canBeSubmitted; - final UidObj classGroup; - final bool canAttach; - - Homework({ - required this.uid, - required this.subject, - required this.subjectName, - required this.teacherName, - required this.description, - required this.startDate, - required this.dueDate, - required this.creationDate, - required this.isCreatedByTeacher, - required this.isDone, - required this.canBeSubmitted, - required this.classGroup, - required this.canAttach, - }); - - factory Homework.fromJson(Map json) { - return Homework( - uid: json["Uid"], - subject: Subject.fromJson(json["Tantargy"]), - subjectName: json["TantargyNeve"], - teacherName: json["RogzitoTanarNeve"], - description: json["Szoveg"], - startDate: DateTime.parse(json["FeladasDatuma"]).toLocal(), - dueDate: DateTime.parse(json["HataridoDatuma"]).toLocal(), - creationDate: DateTime.parse(json["RogzitesIdopontja"]).toLocal(), - isCreatedByTeacher: json["IsTanarRogzitette"], - isDone: json["IsMegoldva"], - canBeSubmitted: json["IsBeadhato"], - classGroup: UidObj.fromJson(json["OsztalyCsoport"]), - canAttach: json["IsCsatolasEngedelyezes"], - ); - } - - @override - String toString() { - return 'Homework(' - 'uid: "$uid", ' - 'subject: $subject, ' - 'subjectName: "$subjectName", ' - 'teacherName: "$teacherName", ' - 'description: "$description", ' - 'startDate: $startDate, ' - 'dueDate: $dueDate, ' - 'creationDate: $creationDate, ' - 'isCreatedByTeacher: $isCreatedByTeacher, ' - 'isDone: $isDone, ' - 'canBeSubmitted: $canBeSubmitted, ' - 'classGroup: $classGroup, ' - 'canAttach: $canAttach' - ')'; - } -} diff --git a/firka/lib/api/model/institution.dart b/firka/lib/api/model/institution.dart deleted file mode 100644 index 5424854..0000000 --- a/firka/lib/api/model/institution.dart +++ /dev/null @@ -1,89 +0,0 @@ -class Institution { - final CustomizationSettings customizationSettings; - final String shortName; - final List systemModuleList; - final String uid; - - Institution({ - required this.customizationSettings, - required this.shortName, - required this.systemModuleList, - required this.uid, - }); - - factory Institution.fromJson(Map json) { - var systemModuleList = List.empty(growable: true); - - for (var item in json['Rendszermodulok']) { - systemModuleList.add(SystemModule.fromJson(item)); - } - - return Institution( - customizationSettings: CustomizationSettings.fromJson( - json['TestreszabasBeallitasok'], - ), - shortName: json['RovidNev'], - systemModuleList: systemModuleList, - uid: json['Uid'], - ); - } -} - -class CustomizationSettings { - final int delayForNotifications; - final bool isClassAverageVisible; - final bool isLessonsThemeVisible; - final String nextServerDeployAsString; - - CustomizationSettings({ - required this.delayForNotifications, - required this.isClassAverageVisible, - required this.isLessonsThemeVisible, - required this.nextServerDeployAsString, - }); - - factory CustomizationSettings.fromJson(Map json) { - return CustomizationSettings( - delayForNotifications: - json['ErtekelesekMegjelenitesenekKesleltetesenekMerteke'], - isClassAverageVisible: json['IsOsztalyAtlagMegjeleniteseEllenorzoben'], - isLessonsThemeVisible: json['IsTanorakTemajaMegtekinthetoEllenorzoben'], - nextServerDeployAsString: json['KovetkezoTelepitesDatuma'], - ); - } - - @override - String toString() { - return 'CustomizationSettings(' - 'delayForNotifications: $delayForNotifications, ' - 'isClassAverageVisible: $isClassAverageVisible, ' - 'isLessonsThemeVisible: $isLessonsThemeVisible, ' - 'nextServerDeployAsString: "$nextServerDeployAsString"' - ')'; - } -} - -class SystemModule { - final bool isActive; - final String type; - final String? url; - - SystemModule({required this.isActive, required this.type, required this.url}); - - factory SystemModule.fromJson(Map json) { - return SystemModule( - isActive: json['IsAktiv'], - type: json['Tipus'], - url: json['Url'], - ); - } - - @override - String toString() { - return 'SystemModule(' - 'isActive: $isActive, ' - 'type: "$type", ' - 'url: "$url"' - ')'; - } -} diff --git a/firka/lib/api/model/notice_board.dart b/firka/lib/api/model/notice_board.dart deleted file mode 100644 index 78738ef..0000000 --- a/firka/lib/api/model/notice_board.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:firka/api/model/generic.dart'; - -class NoticeBoardItem { - final String uid; - final String author; - final DateTime validFrom; - final DateTime validTo; - final String title; - final String contentHTML; - final String contentText; - - NoticeBoardItem({ - required this.uid, - required this.author, - required this.validFrom, - required this.validTo, - required this.title, - required this.contentHTML, - required this.contentText, - }); - - factory NoticeBoardItem.fromJson(Map json) { - return NoticeBoardItem( - uid: json['Uid'], - author: json['RogzitoNeve'], - validFrom: DateTime.parse(json['ErvenyessegKezdete']), - validTo: DateTime.parse(json['ErvenyessegVege']), - title: json['Cim'], - contentHTML: json['Tartalom'], - contentText: json['TartalomText'], - ); - } - - @override - String toString() { - return 'NoticeBoardItem(' - 'uid: "$uid", ' - 'author: "$author", ' - 'validFrom: "$validFrom", ' - 'validTo: "$validTo", ' - 'title: "$title", ' - 'contentHTML: "$contentHTML", ' - 'contentText: "$contentText"' - ')'; - } -} - -class InfoBoardItem { - final String uid; - final String title; - final DateTime date; - final String author; - final DateTime createdAt; - final String contentHTML; - final String contentText; - final NameUidDesc type; - - InfoBoardItem({ - required this.uid, - required this.title, - required this.date, - required this.author, - required this.createdAt, - required this.contentHTML, - required this.contentText, - required this.type, - }); - - factory InfoBoardItem.fromJson(Map json) { - return InfoBoardItem( - uid: json['Uid'], - title: json['Cim'], - date: DateTime.parse(json['Datum']), - author: json['KeszitoTanarNeve'], - createdAt: DateTime.parse(json['KeszitesDatuma']), - contentText: json['Tartalom'], - contentHTML: json['TartalomFormazott'], - type: NameUidDesc.fromJson(json['Tipus']), - ); - } - - @override - String toString() { - return 'InfoBoard(' - 'uid: "$uid", ' - 'title: "$title", ' - 'date: "$date", ' - 'author: "$author", ' - 'createdAt: "$createdAt", ' - 'contentText: "$contentText", ' - 'contentHTML: "$contentHTML", ' - 'type: $type' - ')'; - } -} diff --git a/firka/lib/api/model/omission.dart b/firka/lib/api/model/omission.dart deleted file mode 100644 index fc17c0c..0000000 --- a/firka/lib/api/model/omission.dart +++ /dev/null @@ -1,96 +0,0 @@ -import 'package:firka/api/model/generic.dart'; -import 'package:firka/api/model/subject.dart'; - -class Omission { - final String uid; - final Subject subject; - final Class? c; - final DateTime date; - final String teacher; - final NameUidDesc? type; - final NameUidDesc? mode; - final int? lateForMin; - final DateTime createdAt; - final String state; - final NameUidDesc? proofType; - final UidObj? classGroup; - - Omission({ - required this.uid, - required this.subject, - required this.c, - required this.date, - required this.teacher, - this.type, - this.mode, - this.lateForMin, - required this.createdAt, - required this.state, - required this.proofType, - this.classGroup, - }); - - factory Omission.fromJson(Map json) { - return Omission( - uid: json['Uid'], - subject: Subject.fromJson(json['Tantargy']), - c: json['Osztaly'] != null ? Class.fromJson(json['Osztaly']) : null, - date: DateTime.parse(json['Datum']).toLocal(), - teacher: json['RogzitoTanarNeve'], - type: json['Tipus'] != null ? NameUidDesc.fromJson(json['Tipus']) : null, - mode: json['Mod'] != null ? NameUidDesc.fromJson(json['Mod']) : null, - lateForMin: json['KesesPercben'], - createdAt: DateTime.parse(json['KeszitesDatuma']).toLocal(), - state: json['IgazolasAllapota'], - proofType: json['IgazolasTipusa'] != null - ? NameUidDesc.fromJson(json['IgazolasTipusa']) - : null, - classGroup: json['OsztalyCsoport'] != null - ? UidObj.fromJson(json['OsztalyCsoport']) - : null, - ); - } - - @override - String toString() { - return 'Omission(' - 'uid: "$uid", ' - 'subject: $subject, ' - 'c: $c, ' - 'date: $date, ' - 'teacher: "$teacher", ' - 'type: $type, ' - 'mode: $mode, ' - 'lateForMin: $lateForMin, ' - 'createdAt: $createdAt, ' - 'state: "$state", ' - 'proofType: $proofType, ' - 'classGroup: $classGroup' - ')'; - } -} - -class Class { - final DateTime start; - final DateTime end; - final int classNo; - - Class({required this.start, required this.end, required this.classNo}); - - factory Class.fromJson(Map json) { - return Class( - start: DateTime.parse(json['KezdoDatum']).toLocal(), - end: DateTime.parse(json['VegDatum']).toLocal(), - classNo: json['Oraszam'], - ); - } - - @override - String toString() { - return 'Class(' - 'start: "$start", ' - 'end: "$end", ' - 'classNo: $classNo' - ')'; - } -} diff --git a/firka/lib/api/model/student.dart b/firka/lib/api/model/student.dart deleted file mode 100644 index 4d7d2e5..0000000 --- a/firka/lib/api/model/student.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:firka/api/model/guardian.dart'; -import 'package:firka/api/model/institution.dart'; -import 'package:firka/core/json_helper.dart'; -import 'package:intl/intl.dart'; - -class Student { - final List addressDataList; - final BankAccount bankAccount; - - // final int yearOfBirth; - // final int monthOfBirth; - // final int dayOfBirth; - final DateTime birthdate; - - final String? emailAddress; - final String name; - final String? phoneNumber; - - final String schoolYearUID; - final String uid; - - final List guardianList; - final String instituteCode; - final String instituteName; - - final Institution institution; - - Student({ - required this.addressDataList, - required this.bankAccount, - // required this.yearOfBirth, - // required this.monthOfBirth, - // required this.dayOfBirth, - required this.birthdate, - required this.emailAddress, - required this.name, - required this.phoneNumber, - required this.schoolYearUID, - required this.uid, - required this.guardianList, - required this.instituteCode, - required this.instituteName, - required this.institution, - }); - - factory Student.fromJson(Map json) { - var guardianList = List.empty(growable: true); - - for (var item in json['Gondviselok']) { - guardianList.add(Guardian.fromJson(item)); - } - - return Student( - addressDataList: listToTyped(json['Cimek']), - bankAccount: BankAccount.fromJson(json['Bankszamla']), - birthdate: DateFormat('yyyy-M-d').parse( - "${json['SzuletesiEv']}-${json['SzuletesiHonap']}-${json['SzuletesiNap']}", - ), - emailAddress: json['EmailCim'], - name: json['Nev'], - phoneNumber: json['Telefonszam'], - schoolYearUID: json['TanevUid'], - uid: json['Uid'], - guardianList: guardianList, - instituteCode: json['IntezmenyAzonosito'], - instituteName: json['IntezmenyNev'], - institution: Institution.fromJson(json['Intezmeny']), - ); - } - - @override - String toString() { - return 'Student(' - 'addressDataList: [$addressDataList], ' - 'bankAccount: $bankAccount, ' - 'birthDate: $birthdate, ' - 'emailAddress: "$emailAddress", ' - 'name: "$name", ' - 'phoneNumber: "$phoneNumber", ' - 'schoolYearUID: "$schoolYearUID", ' - 'uid: "$uid", ' - 'guardianList: [$guardianList], ' - 'instituteCode: "$instituteCode", ' - 'instituteName: "$instituteName", ' - ')'; - } -} - -class BankAccount { - final String? accountNumber; - final bool? isReadOnly; - final String? ownerName; - final int? ownerType; - - BankAccount({ - required this.accountNumber, - required this.isReadOnly, - required this.ownerName, - required this.ownerType, - }); - - factory BankAccount.fromJson(Map json) { - return BankAccount( - accountNumber: json['BankszamlaSzam'], - isReadOnly: json['IsReadOnly'], - ownerName: json['BankszamlaTulajdonosNeve'], - ownerType: json['BankszamlaTulajdonosTipusId'], - ); - } - - @override - String toString() { - return 'BankAccount(' - 'accountNumber: "$accountNumber", ' - 'isReadOnly: "$isReadOnly", ' - 'ownerName: "$ownerName", ' - 'ownerType: "$ownerType"' - ')'; - } -} diff --git a/firka/lib/api/model/subject.dart b/firka/lib/api/model/subject.dart deleted file mode 100644 index 25060b4..0000000 --- a/firka/lib/api/model/subject.dart +++ /dev/null @@ -1,48 +0,0 @@ -import 'generic.dart'; - -class Subject { - final String uid; - final String name; - final NameUidDesc category; - final int sortIndex; - final String? teacherName; - - Subject({ - required this.uid, - required this.name, - required this.category, - required this.sortIndex, - this.teacherName, - }); - - factory Subject.fromJson(Map json) { - return Subject( - uid: json['Uid'], - name: json['Nev'], - category: NameUidDesc.fromJson(json['Kategoria']), - sortIndex: json['SortIndex'], - teacherName: json['alkalmazottNev'], - ); - } - - Map toJson() { - return { - 'Uid': uid, - 'Nev': name, - 'Kategoria': category.toJson(), - 'SortIndex': sortIndex, - 'alkalmazottNev': teacherName, - }; - } - - @override - String toString() { - return 'Subject(' - 'uid: "$uid", ' - 'name: "$name", ' - 'category: $category, ' - 'sortIndex: $sortIndex, ' - 'nameOfTeacher: $teacherName' - ')'; - } -} diff --git a/firka/lib/api/model/test.dart b/firka/lib/api/model/test.dart deleted file mode 100644 index 353af77..0000000 --- a/firka/lib/api/model/test.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:firka/api/model/subject.dart'; - -import 'generic.dart'; - -class Test { - final String uid; - final DateTime date; - final DateTime reportDate; - final String teacherName; - final int lessonNumber; - final Subject subject; - final String subjectName; - final String theme; - final NameUidDesc method; - final UidObj classGroup; - - Test({ - required this.uid, - required this.date, - required this.reportDate, - required this.teacherName, - required this.lessonNumber, - required this.subject, - required this.subjectName, - required this.theme, - required this.method, - required this.classGroup, - }); - - factory Test.fromJson(Map json) { - return Test( - uid: json['Uid'], - date: DateTime.parse(json['Datum']).toLocal(), - reportDate: DateTime.parse(json['BejelentesDatuma']).toLocal(), - teacherName: json['RogzitoTanarNeve'], - lessonNumber: json['OrarendiOraOraszama'], - subject: Subject.fromJson(json['Tantargy']), - subjectName: json['TantargyNeve'], - theme: json['Temaja'], - method: NameUidDesc.fromJson(json['Modja']), - classGroup: UidObj.fromJson(json['OsztalyCsoport']), - ); - } - - @override - String toString() { - return 'Test(' - 'uid: "$uid", ' - 'date: $date, ' - 'reportDate: $reportDate, ' - 'teacherName: "$teacherName", ' - 'lessonNumber: $lessonNumber, ' - 'subject: $subject, ' - 'subjectName: "$subjectName", ' - 'theme: "$theme", ' - 'method: $method, ' - 'classGroup: $classGroup' - ')'; - } -} diff --git a/firka/lib/api/model/timetable.dart b/firka/lib/api/model/timetable.dart deleted file mode 100644 index d9b5c2c..0000000 --- a/firka/lib/api/model/timetable.dart +++ /dev/null @@ -1,190 +0,0 @@ -import 'package:firka/api/model/generic.dart'; -import 'package:firka/api/model/subject.dart'; - -class Lesson { - final String uid; - final String date; - final DateTime start; - final DateTime end; - final String name; - final int? lessonNumber; - final int? lessonSeqNumber; - final NameUid? classGroup; - final String? teacher; - final Subject? subject; - final String? theme; - final String? roomName; - final NameUidDesc type; - final NameUidDesc? studentPresence; - final NameUidDesc state; - final String? substituteTeacher; - final String? homeworkUid; - final String? taskGroupUid; - final String? languageTaskGroupUid; - final String? assessmentUid; - final bool canStudentEditHomework; - final bool isHomeworkComplete; - final List attachments; - final bool isDigitalLesson; - final String? digitalDeviceList; - final String? digitalPlatformType; - final List digitalSupportDeviceTypeList; - final DateTime createdAt; - final DateTime lastModifiedAt; - - Lesson({ - required this.uid, - required this.date, - required this.start, - required this.end, - required this.name, - this.lessonNumber, - this.lessonSeqNumber, - this.classGroup, - this.teacher, - this.subject, - this.theme, - this.roomName, - required this.type, - this.studentPresence, - required this.state, - this.substituteTeacher, - this.homeworkUid, - this.taskGroupUid, - this.languageTaskGroupUid, - this.assessmentUid, - required this.canStudentEditHomework, - required this.isHomeworkComplete, - required this.attachments, - required this.isDigitalLesson, - this.digitalDeviceList, - this.digitalPlatformType, - required this.digitalSupportDeviceTypeList, - required this.createdAt, - required this.lastModifiedAt, - }); - - factory Lesson.fromJson(Map json) { - var attachments = List.empty(growable: true); - var rawAttachments = json['Csatolmanyok']; - - for (var attachment in rawAttachments) { - attachments.add(NameUid.fromJson(attachment)); - } - return Lesson( - uid: json['Uid'], - date: json['Datum'], - start: DateTime.parse(json['KezdetIdopont']).toLocal(), - end: DateTime.parse(json['VegIdopont']).toLocal(), - name: json['Nev'], - lessonNumber: json['Oraszam'], - lessonSeqNumber: json['OraEvesSorszama'], - classGroup: json['OsztalyCsoport'] != null - ? NameUid.fromJson(json['OsztalyCsoport']) - : null, - teacher: json['TanarNeve'], - subject: json['Tantargy'] != null - ? Subject.fromJson(json['Tantargy']) - : null, - theme: json['Tema'], - roomName: json['TeremNeve'], - type: NameUidDesc.fromJson(json['Tipus']), - studentPresence: json['TanuloJelenlet'] != null - ? NameUidDesc.fromJson(json['TanuloJelenlet']) - : null, - state: NameUidDesc.fromJson(json['Allapot']), - substituteTeacher: json['HelyettesTanarNeve'], - homeworkUid: json['HaziFeladatUid'], - taskGroupUid: json['FeladatGroupUid'], - languageTaskGroupUid: json['NyelviFeladatGroupUid'], - assessmentUid: json['BejelentettSzamonkeresUid'], - canStudentEditHomework: json['IsTanuloHaziFeladatEnabled'], - isHomeworkComplete: json['IsHaziFeladatMegoldva'], - attachments: attachments, - isDigitalLesson: json['IsDigitalisOra'], - digitalDeviceList: json['DigitalisEszkozTipus'], - digitalPlatformType: json['DigitalisPlatformTipus'], - digitalSupportDeviceTypeList: - json['DigitalisTamogatoEszkozTipusList'] != null - ? List.from(json['DigitalisTamogatoEszkozTipusList']) - : List.empty(), - createdAt: DateTime.parse(json['Letrehozas']).toLocal(), - lastModifiedAt: DateTime.parse(json['UtolsoModositas']).toLocal(), - ); - } - - Map toJson() { - List rawAttachments = []; - - for (var item in attachments) { - rawAttachments.add(item.toJson()); - } - - return { - 'Uid': uid, - 'Datum': date, - 'KezdetIdopont': start.toIso8601String(), - 'VegIdopont': end.toIso8601String(), - 'Nev': name, - 'Oraszam': lessonNumber, - 'OraEvesSorszama': lessonSeqNumber, - 'OsztalyCsoport': classGroup?.toJson(), - 'TanarNeve': teacher, - 'Tantargy': subject?.toJson(), - 'Tema': theme, - 'TeremNeve': roomName, - 'Tipus': type.toJson(), - 'TanuloJelenlet': studentPresence?.toJson(), - 'Allapot': state.toJson(), - 'HelyettesTanarNeve': substituteTeacher, - 'HaziFeladatUid': homeworkUid, - 'FeladatGroupUid': taskGroupUid, - 'NyelviFeladatGroupUid': languageTaskGroupUid, - 'BejelentettSzamonkeresUid': assessmentUid, - 'IsTanuloHaziFeladatEnabled': canStudentEditHomework, - 'IsHaziFeladatMegoldva': isHomeworkComplete, - 'Csatolmanyok': rawAttachments, - 'IsDigitalisOra': isDigitalLesson, - 'DigitalisEszkozTipus': digitalDeviceList, - 'DigitalisPlatformTipus': digitalPlatformType, - 'DigitalisTamogatoEszkozTipusList': digitalSupportDeviceTypeList, - 'Letrehozas': createdAt.toIso8601String(), - 'UtolsoModositas': lastModifiedAt.toIso8601String(), - }; - } - - @override - String toString() { - return 'Lesson(' - 'uid: "$uid", ' - 'date: "$date", ' - 'start: $start, ' - 'end: $end, ' - 'name: "$name", ' - 'lessonNumber: $lessonNumber, ' - 'lessonSeqNumber: $lessonSeqNumber, ' - 'classGroup: $classGroup, ' - 'teacher: "$teacher", ' - 'subject: $subject, ' - 'theme: "$theme", ' - 'roomName: "$roomName", ' - 'type: $type, ' - 'studentPresence: $studentPresence, ' - 'state: $state, ' - 'substituteTeacher: "$substituteTeacher", ' - 'homeworkUid: "$homeworkUid", ' - 'taskGroupUid: "$taskGroupUid", ' - 'languageTaskGroupUid: "$languageTaskGroupUid", ' - 'assessmentUid: "$assessmentUid", ' - 'canStudentEditHomework: $canStudentEditHomework, ' - 'isHomeworkComplete: $isHomeworkComplete, ' - 'attachments: $attachments, ' - 'isDigitalLesson: $isDigitalLesson, ' - 'digitalDeviceList: "$digitalDeviceList", ' - 'digitalPlatformType: "$digitalPlatformType", ' - 'digitalSupportDeviceTypeList: $digitalSupportDeviceTypeList, ' - 'create: $createdAt, ' - 'lastModified: $lastModifiedAt' - ')'; - } -} diff --git a/firka/lib/api/resp/token_grant.dart b/firka/lib/api/resp/token_grant.dart deleted file mode 100644 index 1bedf05..0000000 --- a/firka/lib/api/resp/token_grant.dart +++ /dev/null @@ -1,38 +0,0 @@ -class TokenGrantResponse { - final String idToken; - final String accessToken; - final int expiresIn; - final String tokenType; - final String refreshToken; - final String scope; - - TokenGrantResponse({ - required this.idToken, - required this.accessToken, - required this.expiresIn, - required this.tokenType, - required this.refreshToken, - required this.scope, - }); - - factory TokenGrantResponse.fromJson(Map json) { - return TokenGrantResponse( - idToken: json['id_token'], - accessToken: json['access_token'], - expiresIn: json['expires_in'], - tokenType: json['token_type'], - refreshToken: json['refresh_token'], - scope: json['scope'], - ); - } - - @override - String toString() { - return 'TokenGrant(idToken: "$idToken", accessToken: "$accessToken", ' - 'expiresIn: $expiresIn, ' - 'tokenType: "$tokenType", ' - 'refreshToken: "$refreshToken", ' - 'scope: "$scope"' - ')'; - } -} diff --git a/firka/lib/api/token_grant.dart b/firka/lib/api/token_grant.dart index 92a6797..a4f679c 100644 --- a/firka/lib/api/token_grant.dart +++ b/firka/lib/api/token_grant.dart @@ -1,7 +1,6 @@ import 'package:dio/dio.dart'; -import 'package:firka/api/exceptions/token.dart'; -import 'package:firka/api/resp/token_grant.dart'; import 'package:firka/data/models/token_model.dart'; +import 'package:kreta_api/kreta_api.dart' hide KretaEndpoints; import 'package:firka/app/app_state.dart'; import 'consts.dart'; diff --git a/firka/lib/core/average_helper.dart b/firka/lib/core/average_helper.dart index b7255da..4f04b1a 100644 --- a/firka/lib/core/average_helper.dart +++ b/firka/lib/core/average_helper.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; double calculateAverage(List sortedGrades) { double totalWeight = 0.0; diff --git a/firka/lib/core/extensions.dart b/firka/lib/core/extensions.dart index f526e71..8eb59a5 100644 --- a/firka/lib/core/extensions.dart +++ b/firka/lib/core/extensions.dart @@ -1,6 +1,6 @@ import 'package:intl/intl.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/l10n/app_localizations.dart'; diff --git a/firka/lib/data/ios_widget_helper.dart b/firka/lib/data/ios_widget_helper.dart index 2ca9414..fc9a4a3 100644 --- a/firka/lib/data/ios_widget_helper.dart +++ b/firka/lib/data/ios_widget_helper.dart @@ -1,8 +1,7 @@ import 'dart:convert'; import 'dart:io'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; diff --git a/firka/lib/data/models/token_model.dart b/firka/lib/data/models/token_model.dart index d339176..01c0523 100644 --- a/firka/lib/data/models/token_model.dart +++ b/firka/lib/data/models/token_model.dart @@ -2,7 +2,7 @@ import 'dart:convert'; import 'package:crypto/crypto.dart'; import 'package:dart_jsonwebtoken/dart_jsonwebtoken.dart'; -import 'package:firka/api/resp/token_grant.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/extensions.dart'; import 'package:isar_community/isar.dart'; diff --git a/firka/lib/data/widget.dart b/firka/lib/data/widget.dart index c6cf39f..ae4e347 100644 --- a/firka/lib/data/widget.dart +++ b/firka/lib/data/widget.dart @@ -2,8 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:firka/api/client/kreta_client.dart'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/data/ios_widget_helper.dart'; import 'package:firka/core/settings.dart'; diff --git a/firka/lib/routing/app_router.dart b/firka/lib/routing/app_router.dart index 1e1cfae..482204b 100644 --- a/firka/lib/routing/app_router.dart +++ b/firka/lib/routing/app_router.dart @@ -21,7 +21,7 @@ import 'package:firka/routing/shell_with_nav_bar.dart'; import 'package:firka/routing/swipable_navigator_container.dart'; import 'package:go_router/go_router.dart'; -import 'package:firka/api/model/notice_board.dart'; +import 'package:kreta_api/kreta_api.dart'; GoRouter createAppRouter() { return GoRouter( diff --git a/firka/lib/services/live_activity_manager.dart b/firka/lib/services/live_activity_manager.dart index d04bb79..fa9837c 100644 --- a/firka/lib/services/live_activity_manager.dart +++ b/firka/lib/services/live_activity_manager.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/services.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:logging/logging.dart'; class LiveActivityManager { diff --git a/firka/lib/services/live_activity_service.dart b/firka/lib/services/live_activity_service.dart index e594340..0b23462 100644 --- a/firka/lib/services/live_activity_service.dart +++ b/firka/lib/services/live_activity_service.dart @@ -2,8 +2,7 @@ import 'dart:async'; import 'dart:io'; import 'package:firka/api/client/kreta_client.dart'; import 'package:firka/api/client/live_activity_backend_client.dart'; -import 'package:firka/api/model/generic.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/data/models/app_settings_model.dart'; import 'package:firka/data/widget.dart'; import 'package:firka/services/live_activity_manager.dart'; diff --git a/firka/lib/services/wear_sync_cache.dart b/firka/lib/services/wear_sync_cache.dart index 5e81117..344b3fb 100644 --- a/firka/lib/services/wear_sync_cache.dart +++ b/firka/lib/services/wear_sync_cache.dart @@ -5,8 +5,7 @@ import 'package:path_provider/path_provider.dart' show getApplicationDocumentsDirectory; import 'package:firka/api/client/kreta_client.dart'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; /// File name for the Wear OS sync cache written by the phone (Dart isolate or main). diff --git a/firka/lib/ui/components/common_bottom_sheets.dart b/firka/lib/ui/components/common_bottom_sheets.dart index b0117a4..73eebaa 100644 --- a/firka/lib/ui/components/common_bottom_sheets.dart +++ b/firka/lib/ui/components/common_bottom_sheets.dart @@ -1,7 +1,4 @@ -import 'package:firka/api/model/generic.dart'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/homework.dart'; -import 'package:firka/api/model/subject.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/data/models/homework_cache_model.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/extensions.dart'; @@ -22,10 +19,8 @@ import 'package:firka/ui/phone/pages/home/home_grades.dart'; import 'package:firka/ui/phone/widgets/lesson.dart'; import 'package:go_router/go_router.dart'; import 'package:firka/ui/shared/class_icon.dart'; -import 'package:firka/api/model/timetable.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/grade.dart'; -import 'package:firka/api/model/test.dart'; Future showLessonBottomSheet( BuildContext context, diff --git a/firka/lib/ui/components/grade.dart b/firka/lib/ui/components/grade.dart index 2f2922e..a83e4c3 100644 --- a/firka/lib/ui/components/grade.dart +++ b/firka/lib/ui/components/grade.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:flutter/material.dart'; import 'package:firka/ui/theme/style.dart'; diff --git a/firka/lib/ui/components/grade_helpers.dart b/firka/lib/ui/components/grade_helpers.dart index 3c5f774..caaea9b 100644 --- a/firka/lib/ui/components/grade_helpers.dart +++ b/firka/lib/ui/components/grade_helpers.dart @@ -4,8 +4,7 @@ import 'package:firka/core/settings.dart'; import 'package:firka/app/app_state.dart'; import 'package:firka/ui/theme/style.dart'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/subject.dart'; +import 'package:kreta_api/kreta_api.dart'; int roundGrade(double grade) { final rounding = initData.settings diff --git a/firka/lib/ui/phone/pages/home/home_grades.dart b/firka/lib/ui/phone/pages/home/home_grades.dart index a349f38..32dae70 100644 --- a/firka/lib/ui/phone/pages/home/home_grades.dart +++ b/firka/lib/ui/phone/pages/home/home_grades.dart @@ -1,5 +1,4 @@ -import 'package:firka/api/client/kreta_client.dart'; -import 'package:firka/api/model/generic.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/average_helper.dart'; import 'package:firka/routing/chart_interaction_scope.dart'; import 'package:firka/ui/components/firka_card.dart'; @@ -12,10 +11,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:firka/api/consts.dart'; -import 'package:firka/api/model/class_group.dart'; -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/subject.dart'; -import 'package:firka/api/model/timetable.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/state/firka_state.dart'; import 'package:firka/app/app_state.dart'; diff --git a/firka/lib/ui/phone/pages/home/home_grades_subject.dart b/firka/lib/ui/phone/pages/home/home_grades_subject.dart index 6478f2f..78feef7 100644 --- a/firka/lib/ui/phone/pages/home/home_grades_subject.dart +++ b/firka/lib/ui/phone/pages/home/home_grades_subject.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/components/firka_card.dart'; diff --git a/firka/lib/ui/phone/pages/home/home_main.dart b/firka/lib/ui/phone/pages/home/home_main.dart index 44ff104..017f9d2 100644 --- a/firka/lib/ui/phone/pages/home/home_main.dart +++ b/firka/lib/ui/phone/pages/home/home_main.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:firka/api/client/kreta_stream.dart'; -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/phone/widgets/home_main_starting_soon.dart'; @@ -14,11 +14,6 @@ import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:go_router/go_router.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -import 'package:firka/api/model/homework.dart'; -import 'package:firka/api/model/notice_board.dart'; -import 'package:firka/api/model/student.dart'; -import 'package:firka/api/model/test.dart'; -import 'package:firka/api/model/timetable.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/state/firka_state.dart'; import 'package:firka/ui/components/firka_card.dart'; diff --git a/firka/lib/ui/phone/pages/home/home_timetable.dart b/firka/lib/ui/phone/pages/home/home_timetable.dart index 0a8029e..0062cfc 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable.dart @@ -1,10 +1,8 @@ import 'dart:async'; import 'package:carousel_slider/carousel_slider.dart'; -import 'package:firka/api/client/kreta_client.dart'; import 'package:firka/api/client/kreta_stream.dart'; -import 'package:firka/api/model/test.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/core/settings.dart'; diff --git a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart index 3a01861..e438f2f 100644 --- a/firka/lib/ui/phone/pages/home/home_timetable_mo.dart +++ b/firka/lib/ui/phone/pages/home/home_timetable_mo.dart @@ -1,6 +1,5 @@ import 'package:firka/api/consts.dart'; -import 'package:firka/api/model/omission.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/core/settings.dart'; @@ -13,7 +12,6 @@ import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; import 'package:transparent_pointer/transparent_pointer.dart'; -import 'package:firka/api/model/test.dart'; import 'package:firka/app/app_state.dart'; import 'package:firka/core/bloc/home_refresh_cubit.dart'; import 'package:firka/core/state/firka_state.dart'; diff --git a/firka/lib/ui/phone/screens/home/home_screen.dart b/firka/lib/ui/phone/screens/home/home_screen.dart index e5649c9..2a69742 100644 --- a/firka/lib/ui/phone/screens/home/home_screen.dart +++ b/firka/lib/ui/phone/screens/home/home_screen.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:io'; import 'package:firka/api/client/kreta_stream.dart'; -import 'package:firka/api/exceptions/token.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/core/firka_bundle.dart'; import 'package:firka/services/active_account_helper.dart'; diff --git a/firka/lib/ui/phone/screens/message/message_screen.dart b/firka/lib/ui/phone/screens/message/message_screen.dart index 66263ad..7915333 100644 --- a/firka/lib/ui/phone/screens/message/message_screen.dart +++ b/firka/lib/ui/phone/screens/message/message_screen.dart @@ -3,7 +3,7 @@ import 'package:firka/app/app_state.dart'; import 'package:flutter/material.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -import 'package:firka/api/model/notice_board.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/firka_bundle.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:firka/ui/shared/firka_icon.dart'; diff --git a/firka/lib/ui/phone/widgets/grade_chart.dart b/firka/lib/ui/phone/widgets/grade_chart.dart index f7b0ccf..3933a2a 100644 --- a/firka/lib/ui/phone/widgets/grade_chart.dart +++ b/firka/lib/ui/phone/widgets/grade_chart.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:fl_chart/fl_chart.dart'; diff --git a/firka/lib/ui/phone/widgets/grade_summary_bar.dart b/firka/lib/ui/phone/widgets/grade_summary_bar.dart index b1f8223..f55fd67 100644 --- a/firka/lib/ui/phone/widgets/grade_summary_bar.dart +++ b/firka/lib/ui/phone/widgets/grade_summary_bar.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/grade.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/ui/components/grade.dart'; import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/shared/firka_icon.dart'; diff --git a/firka/lib/ui/phone/widgets/home_main_starting_soon.dart b/firka/lib/ui/phone/widgets/home_main_starting_soon.dart index 56d055b..912adb3 100644 --- a/firka/lib/ui/phone/widgets/home_main_starting_soon.dart +++ b/firka/lib/ui/phone/widgets/home_main_starting_soon.dart @@ -4,7 +4,7 @@ import 'package:firka/ui/theme/style.dart'; import 'package:firka/ui/shared/counter_digit.dart'; import 'package:flutter/material.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; class StartingSoonWidget extends StatelessWidget { final AppLocalizations l10n; diff --git a/firka/lib/ui/phone/widgets/home_main_welcome.dart b/firka/lib/ui/phone/widgets/home_main_welcome.dart index b37fc1d..cdc2170 100644 --- a/firka/lib/ui/phone/widgets/home_main_welcome.dart +++ b/firka/lib/ui/phone/widgets/home_main_welcome.dart @@ -6,8 +6,7 @@ import 'package:firka/ui/shared/firka_icon.dart'; import 'package:flutter/material.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -import 'package:firka/api/model/student.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/ui/theme/style.dart'; class WelcomeWidget extends StatefulWidget { diff --git a/firka/lib/ui/phone/widgets/homework.dart b/firka/lib/ui/phone/widgets/homework.dart index 5f68667..18634d8 100644 --- a/firka/lib/ui/phone/widgets/homework.dart +++ b/firka/lib/ui/phone/widgets/homework.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/homework.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/data/models/homework_cache_model.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/components/firka_card.dart'; diff --git a/firka/lib/ui/phone/widgets/info_board_item.dart b/firka/lib/ui/phone/widgets/info_board_item.dart index 8158b33..4b9516d 100644 --- a/firka/lib/ui/phone/widgets/info_board_item.dart +++ b/firka/lib/ui/phone/widgets/info_board_item.dart @@ -2,7 +2,7 @@ import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:flutter/material.dart'; -import 'package:firka/api/model/notice_board.dart'; +import 'package:kreta_api/kreta_api.dart'; // TODO: Finish class InfoBoardItemWidget extends StatelessWidget { diff --git a/firka/lib/ui/phone/widgets/lesson.dart b/firka/lib/ui/phone/widgets/lesson.dart index d6d9de3..a7a04fc 100644 --- a/firka/lib/ui/phone/widgets/lesson.dart +++ b/firka/lib/ui/phone/widgets/lesson.dart @@ -7,8 +7,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -import 'package:firka/api/model/test.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/debug_helper.dart'; import 'package:firka/ui/components/common_bottom_sheets.dart'; import 'package:firka/ui/shared/class_icon.dart'; diff --git a/firka/lib/ui/phone/widgets/lesson_big.dart b/firka/lib/ui/phone/widgets/lesson_big.dart index 739cf58..d3c5654 100644 --- a/firka/lib/ui/phone/widgets/lesson_big.dart +++ b/firka/lib/ui/phone/widgets/lesson_big.dart @@ -1,4 +1,4 @@ -import 'package:firka/api/model/test.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/l10n/app_localizations.dart'; @@ -8,7 +8,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:majesticons_flutter/majesticons_flutter.dart'; -import 'package:firka/api/model/timetable.dart'; import 'package:firka/ui/shared/class_icon.dart'; class LessonBigWidget extends StatelessWidget { diff --git a/firka/lib/ui/phone/widgets/lesson_small.dart b/firka/lib/ui/phone/widgets/lesson_small.dart index 96270e1..c17e69e 100644 --- a/firka/lib/ui/phone/widgets/lesson_small.dart +++ b/firka/lib/ui/phone/widgets/lesson_small.dart @@ -4,7 +4,7 @@ import 'package:firka/l10n/app_localizations.dart'; import 'package:firka/ui/theme/style.dart'; import 'package:flutter/material.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/ui/shared/class_icon.dart'; class LessonSmallWidget extends StatelessWidget { diff --git a/firka/lib/ui/phone/widgets/notice_board_item.dart b/firka/lib/ui/phone/widgets/notice_board_item.dart index 9b9d1db..4fca685 100644 --- a/firka/lib/ui/phone/widgets/notice_board_item.dart +++ b/firka/lib/ui/phone/widgets/notice_board_item.dart @@ -1,7 +1,7 @@ import 'package:firka/ui/components/firka_card.dart'; import 'package:flutter/material.dart'; -import 'package:firka/api/model/notice_board.dart'; +import 'package:kreta_api/kreta_api.dart'; // TODO: Finish class NoticeBoardItemWidget extends StatelessWidget { diff --git a/firka/lib/ui/phone/widgets/tt_day.dart b/firka/lib/ui/phone/widgets/tt_day.dart index 4752cb6..c6632cf 100644 --- a/firka/lib/ui/phone/widgets/tt_day.dart +++ b/firka/lib/ui/phone/widgets/tt_day.dart @@ -1,5 +1,4 @@ -import 'package:firka/api/model/test.dart'; -import 'package:firka/api/model/timetable.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/core/extensions.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/app/app_state.dart'; diff --git a/firka/lib/ui/shared/grade_small_card.dart b/firka/lib/ui/shared/grade_small_card.dart index 599c5c9..8c6fb24 100644 --- a/firka/lib/ui/shared/grade_small_card.dart +++ b/firka/lib/ui/shared/grade_small_card.dart @@ -1,5 +1,4 @@ -import 'package:firka/api/model/grade.dart'; -import 'package:firka/api/model/subject.dart'; +import 'package:kreta_api/kreta_api.dart'; import 'package:firka/ui/components/firka_card.dart'; import 'package:firka/ui/components/grade_helpers.dart'; import 'package:firka/ui/shared/class_icon.dart'; diff --git a/firka/pubspec.yaml b/firka/pubspec.yaml index c73b539..b60ee83 100644 --- a/firka/pubspec.yaml +++ b/firka/pubspec.yaml @@ -10,6 +10,8 @@ environment: dependencies: flutter: sdk: flutter + kreta_api: + path: ../kreta_api cupertino_icons: ^1.0.8 flutter_launcher_icons: ^0.14.3