reserveSlot method
override
Reserves the slot with slotId
on date
.
If studentId
is provided, the reservation will be made for the student with the given id.
Note: User associated with token
must be a supervisor of the slot.
Implementation
@override
Future<Reservation> reserveSlot({required String token, required int slotId, required DateTime date, int? studentId}) async {
log('Reserving slot $slotId on $date');
final response = await api.callFunction(
function: 'local_lbplanner_slots_book_slot',
body: {
'slotid': slotId,
'date': const ReservationDateTimeConverter().toJson(date),
if (studentId != null) 'studentid': studentId,
},
token: token,
);
response.assertJson();
return Reservation.fromJson(response.asJson);
}