TF-1289: [Domain] Add DestroySubscription in use-case
This commit is contained in:
@@ -30,4 +30,6 @@ abstract class FCMRepository {
|
|||||||
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest);
|
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest);
|
||||||
|
|
||||||
Future<FCMSubscription> getSubscription();
|
Future<FCMSubscription> getSubscription();
|
||||||
|
|
||||||
|
Future<bool> destroySubscription(String subscriptionId);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
|
||||||
|
|
||||||
|
class DestroySubscriptionLoading extends UIState {}
|
||||||
|
|
||||||
|
class DestroySubscriptionSuccess extends UIState {
|
||||||
|
|
||||||
|
final bool destroyedSubscription;
|
||||||
|
|
||||||
|
DestroySubscriptionSuccess(this.destroyedSubscription);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [destroyedSubscription];
|
||||||
|
}
|
||||||
|
|
||||||
|
class DestroySubscriptionFailure extends FeatureFailure {
|
||||||
|
final dynamic exception;
|
||||||
|
|
||||||
|
DestroySubscriptionFailure(this.exception);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [exception];
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:core/presentation/state/failure.dart';
|
||||||
|
import 'package:core/presentation/state/success.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/state/destroy_subscription_state.dart';
|
||||||
|
|
||||||
|
class DestroySubscriptionInteractor {
|
||||||
|
|
||||||
|
final FCMRepository _fcmRepository;
|
||||||
|
|
||||||
|
DestroySubscriptionInteractor(this._fcmRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(String subscriptionId) async* {
|
||||||
|
try {
|
||||||
|
yield Right<Failure, Success>(DestroySubscriptionLoading());
|
||||||
|
final destroyedSubscription = await _fcmRepository.destroySubscription(subscriptionId);
|
||||||
|
yield Right<Failure, Success>(DestroySubscriptionSuccess(destroyedSubscription));
|
||||||
|
} catch (e) {
|
||||||
|
yield Left<Failure, Success>(DestroySubscriptionFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user