/// Use Case: Get Product Reviews
///
/// Fetches reviews for a specific product with pagination.
library;

import 'package:worker/features/reviews/domain/entities/review.dart';
import 'package:worker/features/reviews/domain/repositories/reviews_repository.dart';

/// Use case for getting product reviews
class GetProductReviews {
  const GetProductReviews(this._repository);

  final ReviewsRepository _repository;

  /// Execute the use case
  ///
  /// [itemId] - Product item code
  /// [limitPageLength] - Number of reviews per page (default: 10)
  /// [limitStart] - Pagination offset (default: 0)
  ///
  /// Returns a list of [Review] entities sorted by date (newest first)
  Future<List<Review>> call({
    required String itemId,
    int limitPageLength = 10,
    int limitStart = 0,
  }) async {
    return await _repository.getProductReviews(
      itemId: itemId,
      limitPageLength: limitPageLength,
      limitStart: limitStart,
    );
  }
}
