TF-1205: rename class
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:model/fcm/fcm_token_dto.dart';
|
||||
import 'package:tmail_ui_user/features/caching/fcm_token_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_cache_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_exception.dart';
|
||||
|
||||
class FCMCacheManager {
|
||||
final FcmTokenCacheClient _fcmTokenCacheClient;
|
||||
|
||||
FCMCacheManager(this._fcmTokenCacheClient);
|
||||
|
||||
Future<FCMTokenDto> getFCMToken(String accountId) async {
|
||||
try {
|
||||
final firebase = await _fcmTokenCacheClient.getItem(accountId);
|
||||
if(firebase != null ) {
|
||||
return firebase.toFCMDto();
|
||||
} else {
|
||||
throw NotFoundStoredFCMException();
|
||||
}
|
||||
} catch (e) {
|
||||
logError('FCMCacheManager::getFCM(): $e');
|
||||
throw NotFoundStoredFCMException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setFCMToken(FCMTokenDto firebaseDto) {
|
||||
log('FCMCacheManager::setFCM(): $_fcmTokenCacheClient');
|
||||
return _fcmTokenCacheClient.insertItem(firebaseDto.accountId, firebaseDto.toCache());
|
||||
}
|
||||
|
||||
Future<void> deleteFCMToken(String accountId) {
|
||||
log('FCMCacheManager::deleteSelectedFCM(): $accountId');
|
||||
return _fcmTokenCacheClient.deleteItem(accountId);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:model/firebase/firebase_dto.dart';
|
||||
import 'package:tmail_ui_user/features/caching/firebase_config_cache_client.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/firebase_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/firebase_cache_extensions.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/firebase_exception.dart';
|
||||
|
||||
class FirebaseCacheManager {
|
||||
final FirebaseCacheClient _firebaseCacheClient;
|
||||
|
||||
FirebaseCacheManager(this._firebaseCacheClient);
|
||||
|
||||
Future<FirebaseDto> getFirebase() async {
|
||||
try {
|
||||
final firebase = await _firebaseCacheClient.getItem(FirebaseCache.keyCacheValue);
|
||||
if(firebase != null ) {
|
||||
return firebase.toFirebaseDto();
|
||||
} else {
|
||||
throw NotFoundStoredFirebaseException();
|
||||
}
|
||||
} catch (e) {
|
||||
logError('FirebaseCacheManager::getFirebase(): $e');
|
||||
throw NotFoundStoredFirebaseException();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setFirebase(FirebaseDto firebaseDto) {
|
||||
log('FirebaseCacheManager::setFirebase(): $_firebaseCacheClient');
|
||||
return _firebaseCacheClient.insertItem(firebaseDto.token, firebaseDto.toCache());
|
||||
}
|
||||
|
||||
Future<void> deleteFirebase(String token) {
|
||||
log('FirebaseCacheManager::deleteSelectedFirebase(): $token');
|
||||
return _firebaseCacheClient.deleteItem(token);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user