TF-3591 Implement CalendarEventCounter/accept method
This commit is contained in:
@@ -23,4 +23,8 @@ abstract class CalendarEventDataSource {
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
String? language);
|
||||
|
||||
Future<CalendarEventAcceptResponse> acceptCounterEvent(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds);
|
||||
}
|
||||
@@ -52,4 +52,14 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
|
||||
return await _calendarEventAPI.rejectEventInvitation(accountId, blobIds, language);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventAcceptResponse> acceptCounterEvent(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
) {
|
||||
return Future.sync(() async {
|
||||
return await _calendarEventAPI.acceptCounterEvent(accountId, blobIds);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import 'package:jmap_dart_client/jmap/mail/calendar/parse/calendar_event_parse_m
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/parse/calendar_event_parse_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_method.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_counter_accept_method.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_method.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_reject_method.dart';
|
||||
@@ -192,4 +193,35 @@ class CalendarEventAPI {
|
||||
throw CannotReplyCalendarEventException(mapErrors: calendarEventRejectResponse.notRejected);
|
||||
}
|
||||
}
|
||||
|
||||
Future<CalendarEventAcceptResponse> acceptCounterEvent(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
) async {
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final calendarEventCounterAcceptMethod = CalendarEventCounterAcceptMethod(
|
||||
accountId,
|
||||
blobIds: blobIds.toList());
|
||||
final calendarEventAcceptInvocation = requestBuilder.invocation(
|
||||
calendarEventCounterAcceptMethod,
|
||||
);
|
||||
final response = await (requestBuilder
|
||||
..usings(calendarEventCounterAcceptMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final calendarEventAcceptResponse = response.parse<CalendarEventAcceptResponse>(
|
||||
calendarEventAcceptInvocation.methodCallId,
|
||||
CalendarEventAcceptResponse.deserialize);
|
||||
|
||||
if (calendarEventAcceptResponse == null) {
|
||||
throw NotAcceptableCalendarEventException();
|
||||
}
|
||||
|
||||
if (calendarEventAcceptResponse.accepted?.isNotEmpty == true) {
|
||||
return calendarEventAcceptResponse;
|
||||
} else {
|
||||
throw CannotReplyCalendarEventException(mapErrors: calendarEventAcceptResponse.notAccepted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,4 +85,13 @@ class CalendarEventRepositoryImpl extends CalendarEventRepository {
|
||||
: calendarEvent.description,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventAcceptResponse> acceptCounterEvent(
|
||||
AccountId accountId,
|
||||
Set<Id> blobIds,
|
||||
) {
|
||||
return _calendarEventDataSource[DataSourceType.network]!
|
||||
.acceptCounterEvent(accountId, blobIds);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user