import 'package:krow_core/core.dart';
import '../arguments/sign_in_with_phone_arguments.dart';
import '../repositories/auth_repository_interface.dart';

/// Use case for signing in with a phone number.
///
/// This use case delegates the sign-in logic to the [AuthRepositoryInterface].
class SignInWithPhoneUseCase
    implements UseCase<SignInWithPhoneArguments, String?> {
  final AuthRepositoryInterface _repository;

  /// Creates a [SignInWithPhoneUseCase].
  ///
  /// Requires an [AuthRepositoryInterface] to interact with the authentication data source.
  SignInWithPhoneUseCase(this._repository);

  @override
  Future<String?> call(SignInWithPhoneArguments arguments) {
    return _repository.signInWithPhone(phoneNumber: arguments.phoneNumber);
  }

  void cancelPending() {
    _repository.cancelPendingPhoneVerification();
  }
}
