Allow to get scribePromptUrl from LinagoraEcosystem
This commit is contained in:
@@ -58,4 +58,23 @@ class LinagoraEcosystemApi {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<String?> getScribePromptUrl(String baseUrl) async {
|
||||
LinagoraEcosystem? linagoraEcosystem;
|
||||
|
||||
try {
|
||||
linagoraEcosystem = await getLinagoraEcosystem(baseUrl);
|
||||
} catch (exception) {
|
||||
if (exception is NotFoundLinagoraEcosystem) {
|
||||
return null;
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
|
||||
final scribePromptProperty =
|
||||
linagoraEcosystem.properties?[LinagoraEcosystemIdentifier.scribePromptUrl] as ApiUrlLinagoraEcosystem?;
|
||||
log('LinagoraEcosystemApi::getScribePromptUrl: scribePromptProperty = $scribePromptProperty');
|
||||
|
||||
return scribePromptProperty?.value;
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/network/linagora_ecosystem_api.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/linagora_ecosystem_repository.dart';
|
||||
|
||||
class LinagoraEcosystemRepositoryImpl extends LinagoraEcosystemRepository {
|
||||
final LinagoraEcosystemApi _linagoraEcosystemApi;
|
||||
|
||||
LinagoraEcosystemRepositoryImpl(this._linagoraEcosystemApi);
|
||||
|
||||
@override
|
||||
Future<String?> getScribePromptUrl(String baseUrl) {
|
||||
return _linagoraEcosystemApi.getScribePromptUrl(baseUrl);
|
||||
}
|
||||
}
|
||||
+1
@@ -28,6 +28,7 @@ class LinagoraEcosystemConverter {
|
||||
LinagoraEcosystemIdentifier.linShare: AppLinagoraEcosystem.deserialize,
|
||||
LinagoraEcosystemIdentifier.mobileApps: MobileAppsLinagoraEcosystemConverter.deserialize,
|
||||
LinagoraEcosystemIdentifier.paywallURL: ApiUrlLinagoraEcosystem.deserialize,
|
||||
LinagoraEcosystemIdentifier.scribePromptUrl: ApiUrlLinagoraEcosystem.deserialize,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ class LinagoraEcosystemIdentifier with EquatableMixin {
|
||||
static final twakeSync = LinagoraEcosystemIdentifier('Twake Sync');
|
||||
static final linShare = LinagoraEcosystemIdentifier('LinShare');
|
||||
static final paywallURL = LinagoraEcosystemIdentifier('paywallUrlTemplate');
|
||||
static final scribePromptUrl = LinagoraEcosystemIdentifier('scribePromptUrl');
|
||||
|
||||
final String value;
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class LinagoraEcosystemRepository {
|
||||
Future<String?> getScribePromptUrl(String baseUrl);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:core/presentation/state/success.dart';
|
||||
import 'package:core/presentation/state/failure.dart';
|
||||
|
||||
class GetScribePromptUrlSuccess extends Success {
|
||||
final String? promptUrl;
|
||||
|
||||
GetScribePromptUrlSuccess(this.promptUrl);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [promptUrl];
|
||||
}
|
||||
|
||||
class GetScribePromptUrlFailure extends Failure {
|
||||
final dynamic exception;
|
||||
|
||||
GetScribePromptUrlFailure(this.exception);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [exception];
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import 'package:core/core.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/repository/linagora_ecosystem_repository.dart';
|
||||
import 'package:tmail_ui_user/features/mailbox_dashboard/domain/state/get_scribe_prompt_url_state.dart';
|
||||
|
||||
class GetScribePromptUrlInteractor {
|
||||
final LinagoraEcosystemRepository _linagoraEcosystemRepository;
|
||||
|
||||
GetScribePromptUrlInteractor(this._linagoraEcosystemRepository);
|
||||
|
||||
Stream<Either<Failure, Success>> execute(String baseUrl) async* {
|
||||
try {
|
||||
final promptUrl = await _linagoraEcosystemRepository.getScribePromptUrl(baseUrl);
|
||||
|
||||
yield Right(GetScribePromptUrlSuccess(promptUrl));
|
||||
} catch (e) {
|
||||
yield Left(GetScribePromptUrlFailure(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user