TF-4178 Add datasource/repository/interactor for create new label

This commit is contained in:
dab246
2025-11-26 16:32:53 +07:00
committed by Dat H. Pham
parent 8f1da20e54
commit 38c47ca373
10 changed files with 128 additions and 22 deletions
@@ -10,7 +10,6 @@ import 'package:jmap_dart_client/http/http_client.dart';
import 'package:jmap_dart_client/jmap/account_id.dart';
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
import 'package:jmap_dart_client/jmap/core/capability/core_capability.dart';
import 'package:jmap_dart_client/jmap/core/error/method/error_method_response.dart';
import 'package:jmap_dart_client/jmap/core/error/set_error.dart';
import 'package:jmap_dart_client/jmap/core/id.dart';
import 'package:jmap_dart_client/jmap/core/patch_object.dart';
@@ -197,24 +196,7 @@ class MailboxAPI with HandleSetErrorMixin, MailAPIMixin {
parentId: request.parentId);
return newMailboxCreated;
} else {
throw _parseErrorForSetMailboxResponse(setMailboxResponse, generateCreateId);
}
}
_parseErrorForSetMailboxResponse(SetMailboxResponse? response, Id requestId) {
final mapError = response?.notCreated ?? response?.notUpdated ?? response?.notDestroyed;
if (mapError != null && mapError.containsKey(requestId)) {
final setError = mapError[requestId];
log('MailboxAPI::_parseErrorForSetMailboxResponse():setError: $setError');
if (setError?.type == ErrorMethodResponse.invalidArguments) {
throw InvalidArgumentsMethodResponse(description: setError?.description);
} else if (setError?.type == ErrorMethodResponse.invalidResultReference) {
throw InvalidResultReferenceMethodResponse(description: setError?.description);
} else {
throw UnknownMethodResponse(description: setError?.description);
}
} else {
throw UnknownMethodResponse();
throw parseErrorForSetResponse(setMailboxResponse, generateCreateId);
}
}