Add domain layer for get Session
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
|
|
||||||
|
abstract class SessionRepository {
|
||||||
|
Future<Session> getSession();
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
||||||
|
|
||||||
|
class GetSessionSuccess extends UIState {
|
||||||
|
final Session session;
|
||||||
|
|
||||||
|
GetSessionSuccess(this.session);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [session];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetSessionFailure extends FeatureFailure {
|
||||||
|
final exception;
|
||||||
|
|
||||||
|
GetSessionFailure(this.exception);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [exception];
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:tmail_ui_user/features/session/domain/repository/session_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/session/domain/state/get_session_state.dart';
|
||||||
|
|
||||||
|
class GetSessionInteractor {
|
||||||
|
final SessionRepository sessionRepository;
|
||||||
|
|
||||||
|
GetSessionInteractor(this.sessionRepository);
|
||||||
|
|
||||||
|
Future<Either<Failure, Success>> execute() async {
|
||||||
|
try {
|
||||||
|
final session = await sessionRepository.getSession();
|
||||||
|
return Right<Failure, Success>(GetSessionSuccess(session));
|
||||||
|
} catch (e) {
|
||||||
|
return Left<Failure, Success>(GetSessionFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user