TF-801 Add domain layer for get all vacation
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:forward/forward/tmail_forward.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||
import 'package:jmap_dart_client/jmap/core/properties/properties.dart';
|
||||
import 'package:jmap_dart_client/jmap/identities/identity.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||
import 'package:rule_filter/rule_filter/tmail_rule.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/create_new_identity_request.dart';
|
||||
import 'package:tmail_ui_user/features/manage_account/domain/model/delete_email_rule_request.dart';
|
||||
@@ -32,4 +33,6 @@ abstract class ManageAccountRepository {
|
||||
Future<List<TMailRule>> editEmailRuleFilter(AccountId accountId, EditEmailRuleFilterRequest ruleFilterRequest);
|
||||
|
||||
Future<TMailForward> getForward(AccountId accountId);
|
||||
|
||||
Future<List<VacationResponse>> getAllVacationResponse(AccountId accountId);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||
|
||||
class LoadingGetAllVacation extends UIState {
|
||||
|
||||
LoadingGetAllVacation();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class GetAllVacationSuccess extends UIState {
|
||||
final List<VacationResponse>? listVacationResponse;
|
||||
|
||||
GetAllVacationSuccess(this.listVacationResponse);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [listVacationResponse];
|
||||
}
|
||||
|
||||
class GetAllVacationFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
GetAllVacationFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import 'dart:core';
|
||||
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:jmap_dart_client/jmap/account_id.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/get_all_vacation_state.dart';
|
||||
|
||||
class GetAllVacationInteractor {
|
||||
final ManageAccountRepository manageAccountRepository;
|
||||
|
||||
GetAllVacationInteractor(this.manageAccountRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingGetAllVacation());
|
||||
final listVacationResponse = await manageAccountRepository.getAllVacationResponse(accountId);
|
||||
yield Right<Failure, Success>(GetAllVacationSuccess(listVacationResponse));
|
||||
} catch (exception) {
|
||||
yield Left<Failure, Success>(GetAllVacationFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user