import '../entities/approval.dart';
import '../entities/approval_flow.dart';
import '../repositories/approval_repository.dart';

/// 결재를 상신(submit)하는 유즈케이스.
///
/// - 입력 파라미터는 [ApprovalSubmissionInput]을 사용한다.
class SubmitApprovalUseCase {
  SubmitApprovalUseCase({required ApprovalRepository repository})
    : _repository = repository;

  final ApprovalRepository _repository;

  /// 결재를 상신하고 갱신된 [ApprovalFlow]를 반환한다.
  Future<ApprovalFlow> call(ApprovalSubmissionInput input) async {
    final approval = await _repository.submit(input);
    return ApprovalFlow.fromApproval(approval);
  }
}
