// Copyright (C) 2023 WYATT GROUP
// Please see the AUTHORS file for details.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import 'package:wyatt_architecture/wyatt_architecture.dart';
import 'package:wyatt_authentication_bloc/src/domain/entities/account.dart';

/// {@template authentication_cache_data_source}
/// A data source that manages the cache strategy.
/// {@endtemplate}
abstract class AuthenticationCacheDataSource<Data> extends BaseLocalDataSource {
  /// {@macro authentication_cache_data_source}
  const AuthenticationCacheDataSource();

  /// Returns the cached account if it exists.
  Future<Account?> getCachedAccount();

  /// Adds the current account to the cache.
  ///
  /// If an account is already cached, it will be replaced.
  Future<void> cacheAccount(Account account);

  /// Removes the current account from the cache.
  ///
  /// The cache will be empty after this operation.
  /// If no account is cached, nothing will happen.
  Future<void> removeCachedAccount();
}
