replyWithParticipantStatus method
VCalendar
replyWithParticipantStatus(
- ParticipantStatus participantStatus, {
- String? attendeeEmail,
- AttendeeProperty? attendee,
- String? comment,
- String productId = 'enough_icalendar',
- String? delegatedToEmail,
Creates a repy with the given participantStatus
for the attendee with the given attendeeEmail
or attendee
.
Optionally specify a comment
and specify a productId
Specify the delegatedToEmail
when setting the participantStatus
to ParticipantStatus.delegated
Implementation
VCalendar replyWithParticipantStatus(
ParticipantStatus participantStatus, {
String? attendeeEmail,
AttendeeProperty? attendee,
String? comment,
String productId = 'enough_icalendar',
String? delegatedToEmail,
}) {
assert(attendee != null || attendeeEmail != null,
'Either [attendee] or [attendeeEmail] must be specified.');
final reply = VCalendar()
..productId = productId
..version = '2.0'
..method = Method.reply;
// check if this attendee was delegated:
if (attendee == null) {
Uri? delegatedFrom;
final childEvent =
children.firstWhereOrNull((c) => c is VEvent) as VEvent?;
if (childEvent != null) {
final existing = childEvent.attendees
.firstWhereOrNull((a) => a.email == attendeeEmail);
delegatedFrom = existing?.delegatedFrom;
}
attendee = AttendeeProperty.create(
attendeeEmail: attendeeEmail,
participantStatus: participantStatus,
delegatedToEmail: delegatedToEmail,
delegatedFromUri: delegatedFrom,
);
if (attendee == null) {
throw StateError('Unable to create attendee for $attendeeEmail');
}
}
for (final child in children) {
if (child.canReply) {
final replyChild =
child.reply(attendee, comment: comment, parent: reply);
reply.children.add(replyChild);
break;
}
}
return reply;
}