TF-801 Add domain layer for update vacation
This commit is contained in:
@@ -35,4 +35,6 @@ abstract class ManageAccountRepository {
|
||||
Future<TMailForward> getForward(AccountId accountId);
|
||||
|
||||
Future<List<VacationResponse>> getAllVacationResponse(AccountId accountId);
|
||||
|
||||
Future<List<VacationResponse>> updateVacation(AccountId accountId, VacationResponse vacationResponse);
|
||||
}
|
||||
@@ -11,7 +11,7 @@ class LoadingGetAllVacation extends UIState {
|
||||
}
|
||||
|
||||
class GetAllVacationSuccess extends UIState {
|
||||
final List<VacationResponse>? listVacationResponse;
|
||||
final List<VacationResponse> listVacationResponse;
|
||||
|
||||
GetAllVacationSuccess(this.listVacationResponse);
|
||||
|
||||
|
||||
@@ -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 LoadingUpdateVacation extends UIState {
|
||||
|
||||
LoadingUpdateVacation();
|
||||
|
||||
@override
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class UpdateVacationSuccess extends UIState {
|
||||
final List<VacationResponse> listVacationResponse;
|
||||
|
||||
UpdateVacationSuccess(this.listVacationResponse);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [listVacationResponse];
|
||||
}
|
||||
|
||||
class UpdateVacationFailure extends FeatureFailure {
|
||||
final dynamic exception;
|
||||
|
||||
UpdateVacationFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
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:jmap_dart_client/jmap/mail/vacation/vacation_response.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/update_vacation_state.dart';
|
||||
|
||||
class UpdateVacationInteractor {
|
||||
final ManageAccountRepository manageAccountRepository;
|
||||
|
||||
UpdateVacationInteractor(this.manageAccountRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(AccountId accountId, VacationResponse vacationResponse) async* {
|
||||
try {
|
||||
yield Right<Failure, Success>(LoadingUpdateVacation());
|
||||
final listVacationResponse = await manageAccountRepository.updateVacation(accountId, vacationResponse);
|
||||
yield Right<Failure, Success>(UpdateVacationSuccess(listVacationResponse));
|
||||
} catch (exception) {
|
||||
yield Left<Failure, Success>(UpdateVacationFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user