import 'package:starting_template/domain/entities/integer.dart';
import 'package:starting_template/domain/repositories/counter_repository.dart';
import 'package:wyatt_architecture/wyatt_architecture.dart';

class Decrement extends AsyncUseCase<int, Integer> {
  Decrement({
    required CounterRepository counterRepository,
  }) : _counterRepository = counterRepository;

  final CounterRepository _counterRepository;

  @override
  FutureOrResult<Integer> execute(int? params) async {
    final step = Integer(params ?? 1);

    return _counterRepository.decrement(by: step);
  }
}
