TF-2819 calendar event maybe api & 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/reply/calendar_event_accept_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_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.acceptEventInvitation(accountId, blobIds);
|
||||
}).catchError(_exceptionThrower.throwException);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventMaybeResponse> maybeEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
return Future.sync(() async {
|
||||
return await _calendarEventAPI.maybe(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/reply/calendar_event_accept_response.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_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<CalendarEventAcceptResponse> acceptEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEventMaybeResponse> maybeEventInvitation(AccountId accountId, Set<Id> blobIds) {
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,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_maybe_method.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_maybe_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';
|
||||
|
||||
@@ -65,4 +67,25 @@ class CalendarEventAPI {
|
||||
|
||||
return calendarEventAcceptResponse;
|
||||
}
|
||||
|
||||
Future<CalendarEventMaybeResponse> maybe(AccountId accountId, Set<Id> blobIds) async {
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, ProcessingInvocation());
|
||||
final calendarEventMaybeMethod = CalendarEventMaybeMethod(
|
||||
accountId,
|
||||
blobIds: blobIds.toList());
|
||||
final calendarEventMaybeInvocation = requestBuilder.invocation(calendarEventMaybeMethod);
|
||||
final response = await (requestBuilder..usings(calendarEventMaybeMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final calendarEventMaybeResponse = response.parse<CalendarEventMaybeResponse>(
|
||||
calendarEventMaybeInvocation.methodCallId,
|
||||
CalendarEventMaybeResponse.deserialize);
|
||||
|
||||
if (calendarEventMaybeResponse == null) {
|
||||
throw NotMaybeableCalendarEventException();
|
||||
}
|
||||
|
||||
return calendarEventMaybeResponse;
|
||||
}
|
||||
}
|
||||
@@ -4,3 +4,5 @@ class NotFoundCalendarEventException implements Exception {}
|
||||
class NotParsableCalendarEventException implements Exception {}
|
||||
|
||||
class NotAcceptableCalendarEventException implements Exception {}
|
||||
|
||||
class NotMaybeableCalendarEventException implements Exception {}
|
||||
|
||||
Reference in New Issue
Block a user