import { ITransactionManager } from "@/core/common/infrastructure/database";
import { Collection, Result } from "@repo/rdx-utils";
import { Contact, IContactService } from "../domain";

export class ListContactsUseCase {
  constructor(
    private readonly contactService: IContactService,
    private readonly transactionManager: ITransactionManager
  ) {}

  public execute(): Promise<Result<Collection<Contact>, Error>> {
    return this.transactionManager.complete((transaction) => {
      return this.contactService.findContact(transaction);
    });
  }
}
