TimeSlotFinder
Finds available time slots for a given reservation.
Methods
Inner Classes
Example
This example shows how you can use the class in your own code.
B25.TimeSlotFinder.Context context = new B25.TimeSlotFinder.Context();
// set the reservation to find time slots for
context.reservation = new B25__Reservation__c(
// make sure to populate all fields that are relevant for conflict checking
// and link this reservation to all dimensions that need to be available
B25__Resource__c = someResourceId
// note that start and end times are not necessary
);
// if you need any junctions to be available, map them by relationship name
context.junctions = new Map<String, List<SObject>>{
'B25__Reservation_Contacts__r' => new List<SObject>{
new B25__ReservationContact__c(
B25__Contact__c = someContactId
// note that a reservation id is not necessary
)
}
};
// the time slot context defines what the resulting series of slots should look like
context.timeSlotContext = new B25.TimeSlotGenerator.Context();
context.timeSlotContext.startOfRange = System.now();
context.timeSlotContext.endOfRange = System.now().addDays(7);
context.timeSlotContext.duration = 60;
context.timeSlotContext.interval = 15;
// call the method and do something with the result
B25.TimeSlotFinder.Result result = B25.TimeSlotFinder.findTimeSlots(context);
for (B25.TimeSlot timeSlot : result.timeSlots) {
System.debug('available time slot from ' + timeSlot.startDatetime
+ ' until ' + timeSlot.endDatetime);
}