import 'package:dartz/dartz.dart';
import '../../../../core/errors/failures.dart';
import '../entities/product_entity.dart';
import '../repositories/products_repository.dart';

/// Use case for getting products
/// Encapsulates the business logic for fetching products
class GetProductsUseCase {
  final ProductsRepository repository;

  GetProductsUseCase(this.repository);

  /// Execute the use case
  ///
  /// [warehouseId] - The ID of the warehouse to get products from
  /// [type] - The operation type ('import' or 'export')
  /// [forceRefresh] - If true, bypass cache and fetch from API
  ///
  /// Returns Either<Failure, List<ProductEntity>>
  Future<Either<Failure, List<ProductEntity>>> call(
    int warehouseId,
    String type, {
    bool forceRefresh = false,
  }) async {
    return await repository.getProducts(
      warehouseId,
      type,
      forceRefresh: forceRefresh,
    );
  }
}
