add favorite
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'package:worker/features/products/domain/entities/product.dart';
|
||||
|
||||
/// Favorites Repository Interface
|
||||
///
|
||||
/// Defines the contract for favorites data operations.
|
||||
/// Implementations should follow the online-first approach:
|
||||
/// 1. Try to fetch/update data from API
|
||||
/// 2. Update local cache with API response
|
||||
/// 3. On network failure, fall back to local cache
|
||||
abstract class FavoritesRepository {
|
||||
/// Get favorite products with full product data
|
||||
///
|
||||
/// Online-first: Fetches from wishlist API, caches locally.
|
||||
/// Falls back to local cache on network failure.
|
||||
/// Returns `List<Product>` with complete product information.
|
||||
Future<List<Product>> getFavoriteProducts();
|
||||
|
||||
/// Add a product to favorites
|
||||
///
|
||||
/// Online-first: Adds to API, then caches locally.
|
||||
/// On network failure, queues for later sync.
|
||||
Future<void> addFavorite(String productId);
|
||||
|
||||
/// Remove a product from favorites
|
||||
///
|
||||
/// Online-first: Removes from API, then updates local cache.
|
||||
/// On network failure, queues for later sync.
|
||||
Future<bool> removeFavorite(String productId);
|
||||
}
|
||||
Reference in New Issue
Block a user