36 lines
1.1 KiB
Dart
36 lines
1.1 KiB
Dart
import '../../marianumconnect_query.dart';
|
|
|
|
/// Submits an absence report (`POST absence`, bearer-auth, `source=mobile`).
|
|
/// Empty identity fields are backfilled from LDAP server-side; validation
|
|
/// (all fields required, class must exist, no past start date, end >= start)
|
|
/// also runs server-side and mirrors the client checks. For guardians the
|
|
/// server takes name and class from the child given by [childId].
|
|
class AbsenceSubmit extends MarianumConnectQuery {
|
|
AbsenceSubmit({super.dio});
|
|
|
|
Future<void> run({
|
|
required String firstName,
|
|
required String lastName,
|
|
required String className,
|
|
required DateTime absentFrom,
|
|
required DateTime absentUntil,
|
|
required String phone,
|
|
required String note,
|
|
String? childId,
|
|
}) => guard(() async {
|
|
await dio.post<void>(
|
|
endpoint('absence'),
|
|
data: {
|
|
'firstName': firstName,
|
|
'lastName': lastName,
|
|
'className': className,
|
|
'absentFrom': isoDate(absentFrom),
|
|
'absentUntil': isoDate(absentUntil),
|
|
'phone': phone,
|
|
'note': note,
|
|
'childId': ?childId,
|
|
},
|
|
);
|
|
});
|
|
}
|