TF-2838 calendar event reject api & data source implementation
This commit is contained in:
@@ -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/reply/calendar_event_accept_response.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_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';
|
||||
@@ -41,4 +42,11 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
|
||||
return await _calendarEventAPI.maybe(accountId, blobIds);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventRejectResponse> rejectEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
return Future.sync(() async {
|
||||
return await _calendarEventAPI.reject(accountId, blobIds);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -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/reply/calendar_event_accept_response.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_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';
|
||||
@@ -37,4 +38,9 @@ class LocalCalendarEventDataSourceImpl extends CalendarEventDataSource {
|
||||
Future<CalendarEventMaybeResponse> maybeEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventRejectResponse> rejectEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_
|
||||
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_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';
|
||||
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';
|
||||
import 'package:tmail_ui_user/features/email/presentation/model/blob_calendar_event.dart';
|
||||
|
||||
@@ -88,4 +90,25 @@ class CalendarEventAPI {
|
||||
|
||||
return calendarEventMaybeResponse;
|
||||
}
|
||||
|
||||
Future<CalendarEventRejectResponse> reject(AccountId accountId, Set<Id> 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<CalendarEventRejectResponse>(
|
||||
calendarEventRejectInvocation.methodCallId,
|
||||
CalendarEventRejectResponse.deserialize);
|
||||
|
||||
if (calendarEventRejectResponse == null) {
|
||||
throw NotRejectableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventRejectResponse;
|
||||
}
|
||||
}
|
||||
@@ -6,3 +6,5 @@ class NotParsableCalendarEventException implements Exception {}
|
||||
class NotAcceptableCalendarEventException implements Exception {}
|
||||
|
||||
class NotMaybeableCalendarEventException implements Exception {}
|
||||
|
||||
class NotRejectableCalendarEventException implements Exception {}
|
||||
|
||||
Reference in New Issue
Block a user