import { LoginDatasource } from "../datasource/login_datasource";
import { LoginFormValues } from "../datasource/api/entities/login_form_values";
import { LoggedInUser } from "../datasource/api/entities/user";
import { LoginRepository } from "../../domain/repository/login_repository";

/**
 * Implementation of the LoginRepository interface.
 */
export class LoginRepositoryImpl implements LoginRepository {
  constructor(private datasource: LoginDatasource) {}

  /**
   * Retrieves a token for the given login form values.
   * @param form - The login form values.
   * @returns A promise that resolves to a logged-in user.
   */
  async getToken(form: LoginFormValues): Promise<LoggedInUser> {
    return this.datasource.getToken(form);
  }
}
