forked from firka/firka
ref: kreta_api
This commit is contained in:
@@ -1581,12 +1581,12 @@ class LiveActivityService {
|
||||
final emptyType = NameUidDesc(
|
||||
uid: 'placeholder',
|
||||
name: 'Placeholder',
|
||||
description: null,
|
||||
description: '',
|
||||
);
|
||||
final emptyState = NameUidDesc(
|
||||
uid: 'active',
|
||||
name: 'Active',
|
||||
description: null,
|
||||
description: '',
|
||||
);
|
||||
|
||||
placeholderLesson = Lesson(
|
||||
|
||||
17
kreta_api/lib/src/extensions.dart
Normal file
17
kreta_api/lib/src/extensions.dart
Normal file
@@ -0,0 +1,17 @@
|
||||
extension JsonHelper on Map<String, dynamic> {
|
||||
double? dbl(String key) {
|
||||
final value = this[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return (value as num).toDouble();
|
||||
}
|
||||
|
||||
DateTime? localDate(String key) {
|
||||
final value = this[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return DateTime.parse(value as String).toLocal();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
|
||||
class ClassGroup {
|
||||
@@ -27,17 +28,11 @@ class ClassGroup {
|
||||
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']),
|
||||
headTeacher: json.uid('OsztalyFonok'),
|
||||
substituteHeadTeacher: json.uid('OsztalyFonokHelyettes'),
|
||||
studyGroup: json.nameUidDesc('OktatasNevelesiKategoria')!,
|
||||
studyGroupSortIndex: json['OktatasNevelesiKategoriaSortIndex'],
|
||||
studyTask: json['OktatasNevelesiFeladat'] != null
|
||||
? NameUidDesc.fromJson(json['OktatasNevelesiFeladat'])
|
||||
: null,
|
||||
studyTask: json.nameUidDesc('OktatasNevelesiFeladat'),
|
||||
isActive: json['IsAktiv'],
|
||||
type: json['Tipus'],
|
||||
);
|
||||
@@ -59,9 +54,7 @@ class ClassGroup {
|
||||
}
|
||||
}
|
||||
|
||||
class SubjectAverage {
|
||||
final String uid;
|
||||
final String name;
|
||||
class SubjectAverage extends NameUid {
|
||||
final String? teacherName;
|
||||
final String subjectCategoryId;
|
||||
final String subjectCategoryName;
|
||||
@@ -72,8 +65,8 @@ class SubjectAverage {
|
||||
final int sortIndex;
|
||||
|
||||
SubjectAverage({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
required super.uid,
|
||||
required super.name,
|
||||
this.teacherName,
|
||||
required this.subjectCategoryId,
|
||||
required this.subjectCategoryName,
|
||||
@@ -86,22 +79,18 @@ class SubjectAverage {
|
||||
|
||||
factory SubjectAverage.fromJson(Map<String, dynamic> json) {
|
||||
final tantargy = json['Tantargy'] ?? {};
|
||||
final kategori = tantargy['Kategoria'] ?? {};
|
||||
final kategoria = 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,
|
||||
subjectCategoryId: kategoria['Uid'] ?? '',
|
||||
subjectCategoryName: kategoria['Nev'] ?? '',
|
||||
subjectCategoryDescription: kategoria['Leiras'] ?? '',
|
||||
average: json.dbl('Atlag'),
|
||||
weightedSum: json.dbl('SulyozottOsztalyzatOsszege'),
|
||||
weightedCount: json.dbl('SulyozottOsztalyzatSzama'),
|
||||
sortIndex: tantargy['SortIndex'] ?? 0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
class NameUidDesc {
|
||||
final String uid;
|
||||
final String? name;
|
||||
final String? description;
|
||||
class NameUidDesc extends NameUid {
|
||||
final String description;
|
||||
|
||||
NameUidDesc({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
required super.uid,
|
||||
required super.name,
|
||||
required this.description,
|
||||
});
|
||||
|
||||
@@ -31,11 +29,10 @@ class NameUidDesc {
|
||||
}
|
||||
}
|
||||
|
||||
class NameUid {
|
||||
final String uid;
|
||||
class NameUid extends UidObj {
|
||||
final String name;
|
||||
|
||||
NameUid({required this.uid, required this.name});
|
||||
NameUid({required super.uid, required this.name});
|
||||
|
||||
factory NameUid.fromJson(Map<String, dynamic> json) {
|
||||
return NameUid(uid: json['Uid'], name: json['Nev']);
|
||||
@@ -62,3 +59,29 @@ class UidObj {
|
||||
')';
|
||||
}
|
||||
}
|
||||
|
||||
extension ToUidObj on Map<String, dynamic> {
|
||||
UidObj? uid(String key) {
|
||||
final value = this[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return UidObj.fromJson(value);
|
||||
}
|
||||
|
||||
NameUid? nameUid(String key) {
|
||||
final value = this[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return NameUid.fromJson(value);
|
||||
}
|
||||
|
||||
NameUidDesc? nameUidDesc(String key) {
|
||||
final value = this[key];
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
return NameUidDesc.fromJson(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import 'generic.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class Grade {
|
||||
final String uid;
|
||||
class Grade extends UidObj {
|
||||
final DateTime recordDate;
|
||||
final DateTime creationDate;
|
||||
final DateTime? ackDate;
|
||||
@@ -21,7 +20,7 @@ class Grade {
|
||||
final int sortIndex;
|
||||
|
||||
Grade({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.recordDate,
|
||||
required this.creationDate,
|
||||
this.ackDate,
|
||||
@@ -50,18 +49,16 @@ class Grade {
|
||||
: 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']),
|
||||
type: json.nameUidDesc('Tipus')!,
|
||||
mode: json.nameUidDesc('Mod'),
|
||||
valueType: json.nameUidDesc('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,
|
||||
classGroup: json.uid('OsztalyCsoport'),
|
||||
sortIndex: json['SortIndex'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
class Guardian {
|
||||
import 'generic.dart';
|
||||
|
||||
class Guardian extends NameUid {
|
||||
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 super.name,
|
||||
required this.phoneNumber,
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
});
|
||||
|
||||
factory Guardian.fromJson(Map<String, dynamic> json) {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class Homework {
|
||||
final String uid;
|
||||
class Homework extends UidObj {
|
||||
final Subject subject;
|
||||
final String subjectName;
|
||||
final String teacherName;
|
||||
@@ -17,7 +17,7 @@ class Homework {
|
||||
final bool canAttach;
|
||||
|
||||
Homework({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
required this.subjectName,
|
||||
required this.teacherName,
|
||||
@@ -39,13 +39,13 @@ class Homework {
|
||||
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(),
|
||||
startDate: json.localDate("FeladasDatuma")!,
|
||||
dueDate: json.localDate("HataridoDatuma")!,
|
||||
creationDate: json.localDate("RogzitesIdopontja")!,
|
||||
isCreatedByTeacher: json["IsTanarRogzitette"],
|
||||
isDone: json["IsMegoldva"],
|
||||
canBeSubmitted: json["IsBeadhato"],
|
||||
classGroup: UidObj.fromJson(json["OsztalyCsoport"]),
|
||||
classGroup: json.uid("OsztalyCsoport")!,
|
||||
canAttach: json["IsCsatolasEngedelyezes"],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
class Institution {
|
||||
import 'generic.dart';
|
||||
|
||||
class Institution extends UidObj {
|
||||
final CustomizationSettings customizationSettings;
|
||||
final String shortName;
|
||||
final List<SystemModule> systemModuleList;
|
||||
final String uid;
|
||||
|
||||
Institution({
|
||||
required this.customizationSettings,
|
||||
required this.shortName,
|
||||
required this.systemModuleList,
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
});
|
||||
|
||||
factory Institution.fromJson(Map<String, dynamic> json) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
|
||||
class NoticeBoardItem {
|
||||
final String uid;
|
||||
class NoticeBoardItem extends UidObj {
|
||||
final String author;
|
||||
final DateTime validFrom;
|
||||
final DateTime validTo;
|
||||
@@ -10,7 +10,7 @@ class NoticeBoardItem {
|
||||
final String contentText;
|
||||
|
||||
NoticeBoardItem({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.author,
|
||||
required this.validFrom,
|
||||
required this.validTo,
|
||||
@@ -23,8 +23,8 @@ class NoticeBoardItem {
|
||||
return NoticeBoardItem(
|
||||
uid: json['Uid'],
|
||||
author: json['RogzitoNeve'],
|
||||
validFrom: DateTime.parse(json['ErvenyessegKezdete']),
|
||||
validTo: DateTime.parse(json['ErvenyessegVege']),
|
||||
validFrom: json.localDate('ErvenyessegKezdete')!,
|
||||
validTo: json.localDate('ErvenyessegVege')!,
|
||||
title: json['Cim'],
|
||||
contentHTML: json['Tartalom'],
|
||||
contentText: json['TartalomText'],
|
||||
@@ -45,8 +45,7 @@ class NoticeBoardItem {
|
||||
}
|
||||
}
|
||||
|
||||
class InfoBoardItem {
|
||||
final String uid;
|
||||
class InfoBoardItem extends UidObj {
|
||||
final String title;
|
||||
final DateTime date;
|
||||
final String author;
|
||||
@@ -56,7 +55,7 @@ class InfoBoardItem {
|
||||
final NameUidDesc type;
|
||||
|
||||
InfoBoardItem({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.title,
|
||||
required this.date,
|
||||
required this.author,
|
||||
@@ -70,12 +69,12 @@ class InfoBoardItem {
|
||||
return InfoBoardItem(
|
||||
uid: json['Uid'],
|
||||
title: json['Cim'],
|
||||
date: DateTime.parse(json['Datum']),
|
||||
date: json.localDate('Datum')!,
|
||||
author: json['KeszitoTanarNeve'],
|
||||
createdAt: DateTime.parse(json['KeszitesDatuma']),
|
||||
createdAt: json.localDate('KeszitesDatuma')!,
|
||||
contentText: json['Tartalom'],
|
||||
contentHTML: json['TartalomFormazott'],
|
||||
type: NameUidDesc.fromJson(json['Tipus']),
|
||||
type: json.nameUidDesc('Tipus')!,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class Omission {
|
||||
final String uid;
|
||||
class Omission extends UidObj {
|
||||
final Subject subject;
|
||||
final Class? c;
|
||||
final DateTime date;
|
||||
@@ -16,7 +16,7 @@ class Omission {
|
||||
final UidObj? classGroup;
|
||||
|
||||
Omission({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.subject,
|
||||
required this.c,
|
||||
required this.date,
|
||||
@@ -35,19 +35,15 @@ class Omission {
|
||||
uid: json['Uid'],
|
||||
subject: Subject.fromJson(json['Tantargy']),
|
||||
c: json['Osztaly'] != null ? Class.fromJson(json['Osztaly']) : null,
|
||||
date: DateTime.parse(json['Datum']).toLocal(),
|
||||
date: json.localDate('Datum')!,
|
||||
teacher: json['RogzitoTanarNeve'],
|
||||
type: json['Tipus'] != null ? NameUidDesc.fromJson(json['Tipus']) : null,
|
||||
mode: json['Mod'] != null ? NameUidDesc.fromJson(json['Mod']) : null,
|
||||
type: json.nameUidDesc('Tipus'),
|
||||
mode: json.nameUidDesc('Mod'),
|
||||
lateForMin: json['KesesPercben'],
|
||||
createdAt: DateTime.parse(json['KeszitesDatuma']).toLocal(),
|
||||
createdAt: json.localDate('KeszitesDatuma')!,
|
||||
state: json['IgazolasAllapota'],
|
||||
proofType: json['IgazolasTipusa'] != null
|
||||
? NameUidDesc.fromJson(json['IgazolasTipusa'])
|
||||
: null,
|
||||
classGroup: json['OsztalyCsoport'] != null
|
||||
? UidObj.fromJson(json['OsztalyCsoport'])
|
||||
: null,
|
||||
proofType: json.nameUidDesc('IgazolasTipusa')!,
|
||||
classGroup: json.uid('OsztalyCsoport'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,8 +75,8 @@ class Class {
|
||||
|
||||
factory Class.fromJson(Map<String, dynamic> json) {
|
||||
return Class(
|
||||
start: DateTime.parse(json['KezdoDatum']).toLocal(),
|
||||
end: DateTime.parse(json['VegDatum']).toLocal(),
|
||||
start: json.localDate('KezdoDatum')!,
|
||||
end: json.localDate('VegDatum')!,
|
||||
classNo: json['Oraszam'],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import 'generic.dart';
|
||||
|
||||
class Subject {
|
||||
final String uid;
|
||||
final String name;
|
||||
class Subject extends NameUid {
|
||||
final NameUidDesc category;
|
||||
final int sortIndex;
|
||||
final String? teacherName;
|
||||
|
||||
Subject({
|
||||
required this.uid,
|
||||
required this.name,
|
||||
required super.uid,
|
||||
required super.name,
|
||||
required this.category,
|
||||
required this.sortIndex,
|
||||
this.teacherName,
|
||||
@@ -19,7 +17,7 @@ class Subject {
|
||||
return Subject(
|
||||
uid: json['Uid'],
|
||||
name: json['Nev'],
|
||||
category: NameUidDesc.fromJson(json['Kategoria']),
|
||||
category: json.nameUidDesc('Kategoria')!,
|
||||
sortIndex: json['SortIndex'],
|
||||
teacherName: json['alkalmazottNev'],
|
||||
);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class Test {
|
||||
final String uid;
|
||||
class Test extends UidObj {
|
||||
final DateTime date;
|
||||
final DateTime reportDate;
|
||||
final String teacherName;
|
||||
@@ -14,7 +14,7 @@ class Test {
|
||||
final UidObj classGroup;
|
||||
|
||||
Test({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.date,
|
||||
required this.reportDate,
|
||||
required this.teacherName,
|
||||
@@ -29,15 +29,15 @@ class Test {
|
||||
factory Test.fromJson(Map<String, dynamic> json) {
|
||||
return Test(
|
||||
uid: json['Uid'],
|
||||
date: DateTime.parse(json['Datum']).toLocal(),
|
||||
reportDate: DateTime.parse(json['BejelentesDatuma']).toLocal(),
|
||||
date: json.localDate('Datum')!,
|
||||
reportDate: json.localDate('BejelentesDatuma')!,
|
||||
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']),
|
||||
method: json.nameUidDesc('Modja')!,
|
||||
classGroup: json.uid('OsztalyCsoport')!,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
import '../extensions.dart';
|
||||
import 'generic.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class Lesson {
|
||||
final String uid;
|
||||
class Lesson extends NameUid {
|
||||
final String date;
|
||||
final DateTime start;
|
||||
final DateTime end;
|
||||
final String name;
|
||||
final int? lessonNumber;
|
||||
final int? lessonSeqNumber;
|
||||
final NameUid? classGroup;
|
||||
@@ -33,11 +32,11 @@ class Lesson {
|
||||
final DateTime lastModifiedAt;
|
||||
|
||||
Lesson({
|
||||
required this.uid,
|
||||
required super.uid,
|
||||
required this.date,
|
||||
required this.start,
|
||||
required this.end,
|
||||
required this.name,
|
||||
required super.name,
|
||||
this.lessonNumber,
|
||||
this.lessonSeqNumber,
|
||||
this.classGroup,
|
||||
@@ -74,25 +73,21 @@ class Lesson {
|
||||
return Lesson(
|
||||
uid: json['Uid'],
|
||||
date: json['Datum'],
|
||||
start: DateTime.parse(json['KezdetIdopont']).toLocal(),
|
||||
end: DateTime.parse(json['VegIdopont']).toLocal(),
|
||||
start: json.localDate('KezdetIdopont')!,
|
||||
end: json.localDate('VegIdopont')!,
|
||||
name: json['Nev'],
|
||||
lessonNumber: json['Oraszam'],
|
||||
lessonSeqNumber: json['OraEvesSorszama'],
|
||||
classGroup: json['OsztalyCsoport'] != null
|
||||
? NameUid.fromJson(json['OsztalyCsoport'])
|
||||
: null,
|
||||
classGroup: json.nameUid('OsztalyCsoport'),
|
||||
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']),
|
||||
type: json.nameUidDesc('Tipus')!,
|
||||
studentPresence: json.nameUidDesc('TanuloJelenlet'),
|
||||
state: json.nameUidDesc('Allapot')!,
|
||||
substituteTeacher: json['HelyettesTanarNeve'],
|
||||
homeworkUid: json['HaziFeladatUid'],
|
||||
taskGroupUid: json['FeladatGroupUid'],
|
||||
@@ -108,8 +103,8 @@ class Lesson {
|
||||
json['DigitalisTamogatoEszkozTipusList'] != null
|
||||
? List<String>.from(json['DigitalisTamogatoEszkozTipusList'])
|
||||
: List<String>.empty(),
|
||||
createdAt: DateTime.parse(json['Letrehozas']).toLocal(),
|
||||
lastModifiedAt: DateTime.parse(json['UtolsoModositas']).toLocal(),
|
||||
createdAt: json.localDate('Letrehozas')!,
|
||||
lastModifiedAt: json.localDate('UtolsoModositas')!,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user