TF-2800 Calendar event accept - API and data source implementation
This commit is contained in:
@@ -2,6 +2,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: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';
|
||||
@@ -25,4 +26,11 @@ class CalendarEventDataSourceImpl extends CalendarEventDataSource {
|
||||
Future<List<EventAction>> getListEventAction(String emailContents) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventAcceptResponse> acceptEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
return Future.sync(() async {
|
||||
return await _calendarEventAPI.acceptEventInvitation(accountId, blobIds);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,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: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';
|
||||
@@ -25,4 +26,9 @@ class LocalCalendarEventDataSourceImpl extends CalendarEventDataSource {
|
||||
return await _htmlAnalyzer.getListEventAction(emailContents);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventAcceptResponse> acceptEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import 'package:jmap_dart_client/jmap/jmap_request.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/parse/calendar_event_parse_method.dart';
|
||||
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:tmail_ui_user/features/email/domain/exceptions/calendar_event_exceptions.dart';
|
||||
|
||||
class CalendarEventAPI {
|
||||
@@ -38,4 +40,25 @@ class CalendarEventAPI {
|
||||
throw NotParsableCalendarEventException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<CalendarEventAcceptResponse> acceptEventInvitation(AccountId accountId, Set<Id> blobIds) async {
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final calendarEventAcceptMethod = CalendarEventAcceptMethod(
|
||||
accountId,
|
||||
blobIds: blobIds.toList());
|
||||
final calendarEventAcceptInvocation = requestBuilder.invocation(calendarEventAcceptMethod);
|
||||
final response = await (requestBuilder..usings(calendarEventAcceptMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final calendarEventAcceptResponse = response.parse<CalendarEventAcceptResponse>(
|
||||
calendarEventAcceptInvocation.methodCallId,
|
||||
CalendarEventAcceptResponse.deserialize);
|
||||
|
||||
if (calendarEventAcceptResponse == null) {
|
||||
throw NotAcceptableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventAcceptResponse;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
class NotFoundCalendarEventException implements Exception {}
|
||||
|
||||
class NotParsableCalendarEventException implements Exception {}
|
||||
class NotParsableCalendarEventException implements Exception {}
|
||||
|
||||
class NotAcceptableCalendarEventException implements Exception {}
|
||||
|
||||
Reference in New Issue
Block a user