TF-537 Add domain layer for delete a identity
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/model/identities_response.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/model/identities_response.dart';
|
||||||
|
|
||||||
abstract class ManageAccountRepository {
|
abstract class ManageAccountRepository {
|
||||||
Future<IdentitiesResponse> getAllIdentities(AccountId accountId);
|
Future<IdentitiesResponse> getAllIdentities(AccountId accountId);
|
||||||
|
|
||||||
|
Future<bool> deleteIdentity(AccountId accountId, IdentityId identityId);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
|
||||||
|
class DeleteIdentitySuccess extends UIState {
|
||||||
|
|
||||||
|
DeleteIdentitySuccess();
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DeleteIdentityFailure extends FeatureFailure {
|
||||||
|
final dynamic exception;
|
||||||
|
|
||||||
|
DeleteIdentityFailure(this.exception);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [exception];
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import 'dart:core';
|
||||||
|
|
||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/domain/repository/manage_account_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/manage_account/domain/state/delete_identity_state.dart';
|
||||||
|
|
||||||
|
class DeleteIdentityInteractor {
|
||||||
|
final ManageAccountRepository manageAccountRepository;
|
||||||
|
|
||||||
|
DeleteIdentityInteractor(this.manageAccountRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(AccountId accountId, IdentityId identityId) async* {
|
||||||
|
try {
|
||||||
|
final result = await manageAccountRepository.deleteIdentity(accountId, identityId);
|
||||||
|
yield result ? Right(DeleteIdentitySuccess()) : Left(DeleteIdentityFailure(null));
|
||||||
|
} catch (exception) {
|
||||||
|
yield Left(DeleteIdentityFailure(exception));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user