TF-1810 Add StoreDetailedEmailToCacheInteractor to store detailed email to cache
(cherry picked from commit 60a91537f7ea1225b5ca67f6dd9ef358b33939da)
This commit is contained in:
@@ -2,5 +2,5 @@
|
||||
enum DataSourceType {
|
||||
network,
|
||||
local,
|
||||
cache
|
||||
hiveCache;
|
||||
}
|
||||
@@ -6,13 +6,11 @@ import 'package:path_provider/path_provider.dart';
|
||||
|
||||
class FileUtils {
|
||||
|
||||
Future<String> _getInternalStorageDirPath(
|
||||
String nameFile,
|
||||
{
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}
|
||||
) async {
|
||||
Future<String> _getInternalStorageDirPath({
|
||||
required String nameFile,
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}) async {
|
||||
if (!BuildUtils.isWeb) {
|
||||
|
||||
String fileDirectory = (await getApplicationDocumentsDirectory()).absolute.path;
|
||||
@@ -39,16 +37,14 @@ class FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
Future<File> saveToFile(
|
||||
String nameFile,
|
||||
String content,
|
||||
{
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}) async {
|
||||
|
||||
Future<File> saveToFile({
|
||||
required String nameFile,
|
||||
required String content,
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}) async {
|
||||
final internalStorageDirPath = await _getInternalStorageDirPath(
|
||||
nameFile,
|
||||
nameFile: nameFile,
|
||||
folderPath: folderPath,
|
||||
extensionFile: extensionFile
|
||||
);
|
||||
@@ -59,16 +55,13 @@ class FileUtils {
|
||||
return await file.writeAsString(content, mode: FileMode.append);
|
||||
}
|
||||
|
||||
Future<String> getFromFile(
|
||||
String nameFile,
|
||||
{
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}
|
||||
) async {
|
||||
|
||||
Future<String> getFromFile({
|
||||
required String nameFile,
|
||||
String? folderPath,
|
||||
String? extensionFile
|
||||
}) async {
|
||||
final internalStorageDirPath = await _getInternalStorageDirPath(
|
||||
nameFile,
|
||||
nameFile: nameFile,
|
||||
folderPath: folderPath,
|
||||
extensionFile: extensionFile
|
||||
);
|
||||
@@ -80,4 +73,18 @@ class FileUtils {
|
||||
|
||||
return emailContent;
|
||||
}
|
||||
}
|
||||
|
||||
enum ExtensionType {
|
||||
text,
|
||||
json;
|
||||
|
||||
String get value {
|
||||
switch(this) {
|
||||
case ExtensionType.text:
|
||||
return 'txt';
|
||||
case ExtensionType.json:
|
||||
return 'json';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ void main() {
|
||||
|
||||
test('Store private HTLM String to File', () async {
|
||||
|
||||
final file = await FileUtils().saveToFile(fileName, fileContent);
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
|
||||
expect(await file.exists(), equals(true));
|
||||
|
||||
@@ -28,9 +28,9 @@ void main() {
|
||||
test('Get HTML String from File Private', () async {
|
||||
|
||||
/// Create a temporary file that will be deleted after `getFromFile` is done
|
||||
final file = await FileUtils().saveToFile(fileName, fileContent);
|
||||
final file = await FileUtils().saveToFile(nameFile: fileName, content: fileContent);
|
||||
|
||||
final htmlString = await FileUtils().getFromFile(fileName);
|
||||
final htmlString = await FileUtils().getFromFile(nameFile: fileName);
|
||||
|
||||
expect(htmlString.isNotEmpty, equals(true));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user