diff --git a/lib/features/email/data/datasource_impl/calendar_event_datasource_impl.dart b/lib/features/email/data/datasource_impl/calendar_event_datasource_impl.dart index 4962263db6..fac76189d0 100644 --- a/lib/features/email/data/datasource_impl/calendar_event_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/calendar_event_datasource_impl.dart @@ -3,6 +3,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.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_reject_response.dart'; import 'package:tmail_ui_user/features/email/data/datasource/calendar_event_datasource.dart'; import 'package:tmail_ui_user/features/email/data/network/calendar_event_api.dart'; import 'package:tmail_ui_user/features/email/domain/model/event_action.dart'; @@ -33,4 +34,11 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource { return await _calendarEventAPI.accept(accountId, blobIds); }).catchError(_exceptionThrower.throwException); } + + @override + Future rejectEventInvitation(AccountId accountId, Set blobIds) { + return Future.sync(() async { + return await _calendarEventAPI.reject(accountId, blobIds); + }).catchError(_exceptionThrower.throwException); + } } \ No newline at end of file diff --git a/lib/features/email/data/datasource_impl/local_calendar_event_datasource_impl.dart b/lib/features/email/data/datasource_impl/local_calendar_event_datasource_impl.dart index dcfaf7a99e..d1300ec549 100644 --- a/lib/features/email/data/datasource_impl/local_calendar_event_datasource_impl.dart +++ b/lib/features/email/data/datasource_impl/local_calendar_event_datasource_impl.dart @@ -3,6 +3,7 @@ import 'package:jmap_dart_client/jmap/account_id.dart'; import 'package:jmap_dart_client/jmap/core/id.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.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_reject_response.dart'; import 'package:tmail_ui_user/features/email/data/datasource/calendar_event_datasource.dart'; import 'package:tmail_ui_user/features/email/data/local/html_analyzer.dart'; import 'package:tmail_ui_user/features/email/domain/model/event_action.dart'; @@ -31,4 +32,9 @@ class LocalCalendarEventDataSourceImpl extends CalendarEventDataSource { Future accept(AccountId accountId, Set blobIds) { throw UnimplementedError(); } + + @override + Future rejectEventInvitation(AccountId accountId, Set blobIds) { + throw UnimplementedError(); + } } \ No newline at end of file diff --git a/lib/features/email/data/network/calendar_event_api.dart b/lib/features/email/data/network/calendar_event_api.dart index 46595544fc..8104fc7142 100644 --- a/lib/features/email/data/network/calendar_event_api.dart +++ b/lib/features/email/data/network/calendar_event_api.dart @@ -9,6 +9,8 @@ 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_reject_method.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_reject_response.dart'; import 'package:tmail_ui_user/features/email/domain/exceptions/calendar_event_exceptions.dart'; class CalendarEventAPI { @@ -61,4 +63,25 @@ class CalendarEventAPI { return calendarEventAcceptResponse; } + + Future reject(AccountId accountId, Set blobIds) async { + final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation()); + final calendarEventRejectMethod = CalendarEventRejectMethod( + accountId, + blobIds: blobIds.toList()); + final calendarEventRejectInvocation = requestBuilder.invocation(calendarEventRejectMethod); + final response = await (requestBuilder..usings(calendarEventRejectMethod.requiredCapabilities)) + .build() + .execute(); + + final calendarEventRejectResponse = response.parse( + calendarEventRejectInvocation.methodCallId, + CalendarEventRejectResponse.deserialize); + + if (calendarEventRejectResponse == null) { + throw NotRejectableCalendarEventException(); + } + + return calendarEventRejectResponse; + } } \ No newline at end of file diff --git a/lib/features/email/domain/exceptions/calendar_event_exceptions.dart b/lib/features/email/domain/exceptions/calendar_event_exceptions.dart index 02078195aa..a472a5084f 100644 --- a/lib/features/email/domain/exceptions/calendar_event_exceptions.dart +++ b/lib/features/email/domain/exceptions/calendar_event_exceptions.dart @@ -4,3 +4,5 @@ class NotFoundCalendarEventException implements Exception {} class NotParsableCalendarEventException implements Exception {} class NotAcceptableCalendarEventException implements Exception {} + +class NotRejectableCalendarEventException implements Exception {}