TF-4186 Add datasource/repository for save and get company server login info
This commit is contained in:
@@ -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:tmail_ui_user/features/login/domain/repository/company_server_login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/get_company_server_login_info_state.dart';
|
||||
|
||||
class GetCompanyServerLoginInfoInteractor {
|
||||
final CompanyServerLoginRepository _serverLoginRepository;
|
||||
|
||||
GetCompanyServerLoginInfoInteractor(this._serverLoginRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute() async* {
|
||||
try {
|
||||
yield Right(GettingCompanyServerLoginInfo());
|
||||
final serverLoginInfo =
|
||||
await _serverLoginRepository.getCompanyServerLoginInfo();
|
||||
yield Right(GetCompanyServerLoginInfoSuccess(serverLoginInfo));
|
||||
} catch (exception) {
|
||||
yield Left(GetCompanyServerLoginInfoFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import 'dart:core';
|
||||
|
||||
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/login/domain/model/company_server_login_info.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/repository/company_server_login_repository.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/state/save_company_server_login_info_state.dart';
|
||||
|
||||
class SaveCompanyServerLoginInfoInteractor {
|
||||
final CompanyServerLoginRepository _serverLoginRepository;
|
||||
|
||||
SaveCompanyServerLoginInfoInteractor(this._serverLoginRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(
|
||||
CompanyServerLoginInfo serverLoginInfo,
|
||||
) async* {
|
||||
try {
|
||||
yield Right(SavingCompanyServerLoginInfo());
|
||||
await _serverLoginRepository.saveCompanyServerLoginInfo(serverLoginInfo);
|
||||
yield Right(SaveCompanyServerLoginInfoSuccess());
|
||||
} catch (exception) {
|
||||
yield Left(SaveCompanyServerLoginInfoFailure(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user