import 'package:dartz/dartz.dart';
import '../../../../core/errors/failures.dart';
import '../entities/warehouse_entity.dart';
import '../repositories/warehouse_repository.dart';

/// Use case for getting all warehouses
/// Encapsulates the business logic for fetching warehouses
///
/// Usage:
/// ```dart
/// final useCase = GetWarehousesUseCase(repository);
/// final result = await useCase();
///
/// result.fold(
///   (failure) => print('Error: ${failure.message}'),
///   (warehouses) => print('Loaded ${warehouses.length} warehouses'),
/// );
/// ```
class GetWarehousesUseCase {
  final WarehouseRepository repository;

  GetWarehousesUseCase(this.repository);

  /// Execute the use case
  ///
  /// Returns [Either<Failure, List<WarehouseEntity>>]
  /// - Right: List of warehouses on success
  /// - Left: Failure object with error details
  Future<Either<Failure, List<WarehouseEntity>>> call() async {
    return await repository.getWarehouses();
  }
}
