import 'package:krow_core/core.dart';
import 'package:krow_domain/krow_domain.dart';
import '../repositories/i_view_orders_repository.dart';
import '../arguments/orders_range_arguments.dart';

/// Use case for retrieving the list of client orders.
///
/// This use case encapsulates the business rule of fetching orders
/// and delegates the data retrieval to the [IViewOrdersRepository].
class GetOrdersUseCase
    implements UseCase<OrdersRangeArguments, List<OrderItem>> {
  final IViewOrdersRepository _repository;

  /// Creates a [GetOrdersUseCase] with the required [IViewOrdersRepository].
  GetOrdersUseCase(this._repository);

  @override
  Future<List<OrderItem>> call(OrdersRangeArguments input) {
    return _repository.getOrdersForRange(
      start: input.start,
      end: input.end,
    );
  }
}
