import { ITransactionManager } from "@/core/common/infrastructure/database";
import { LoginData } from "../../domain";
import { IAuthService } from "../../domain/services";

export class LoginUseCase {
  constructor(
    private readonly authService: IAuthService,
    private readonly transactionManager: ITransactionManager
  ) {}

  public async execute(loginData: LoginData) {
    return await this.transactionManager.complete(async (transaction) => {
      return await this.authService.loginUser(loginData, transaction);
    });
  }
}
