TF-832 Add data layer for delete recipient in forwarding
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:async';
|
||||
import 'package:forward/forward/forward_id.dart';
|
||||
import 'package:forward/forward/get/get_forward_method.dart';
|
||||
import 'package:forward/forward/get/get_forward_response.dart';
|
||||
import 'package:forward/forward/set/set_forward_method.dart';
|
||||
import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:jmap_dart_client/http/http_client.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
@@ -260,4 +261,35 @@ class ManageAccountAPI {
|
||||
|
||||
return resultList?.list ?? <VacationResponse>[];
|
||||
}
|
||||
|
||||
Future<TMailForward> updateForward(AccountId accountId, TMailForward forward) async {
|
||||
final setForwardMethod = SetForwardMethod(accountId)
|
||||
..addUpdatesSingleton({
|
||||
ForwardIdSingleton.forwardIdSingleton.id : forward
|
||||
});
|
||||
|
||||
final processingInvocation = ProcessingInvocation();
|
||||
final requestBuilder = JmapRequestBuilder(_httpClient, processingInvocation)
|
||||
..invocation(setForwardMethod);
|
||||
|
||||
final getForwardMethod = GetForwardMethod(accountId)
|
||||
..addIds({ForwardIdSingleton.forwardIdSingleton.id});
|
||||
final getForwardInvocation = requestBuilder.invocation(getForwardMethod);
|
||||
|
||||
final response = await (requestBuilder
|
||||
..usings(setForwardMethod.requiredCapabilities))
|
||||
.build()
|
||||
.execute();
|
||||
|
||||
final getForwardResponse = response.parse<GetForwardResponse>(
|
||||
getForwardInvocation.methodCallId,
|
||||
GetForwardResponse.deserialize);
|
||||
|
||||
final newForward = getForwardResponse?.list.first;
|
||||
if (newForward == null) {
|
||||
throw NotFoundForwardException();
|
||||
}
|
||||
|
||||
return newForward;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user