import { PlaceDatasourceInf } from "../datasource/place_datasource";
import { Place } from "../datasource/api/entities/place";
import { PlaceRepositoryInf } from "../../domain/repository/place_repository";

/**
 * Implementation of the PlaceRepository interface for production.
 */
export class PlaceRepositoryProd implements PlaceRepositoryInf {
  constructor(private datasouce: PlaceDatasourceInf) {}

  /**
   * Registers a new place.
   * @param form - The place data to register.
   * @returns A promise that resolves when the place is registered.
   */
  async registerPlace(form: Place): Promise<void> {
    return this.datasouce.registerPlace(form);
  }

  /**
   * Retrieves places by town.
   * @param idTown - The ID of the town.
   * @returns A promise that resolves to an array of Place objects.
   */
  async getPlacesByTown(idTown: number): Promise<Place[]> {
    return this.datasouce.getPlacesByTown(idTown);
  }

  /**
   * Retrieves a place by its ID.
   * @param idPlace - The ID of the place.
   * @returns A promise that resolves to a Place object.
   */
  async getPlaceById(idPlace: number): Promise<Place> {
    return this.datasouce.getPlaceById(idPlace);
  }

  /**
   * Updates an existing place.
   * @param place - The place data to update.
   * @returns A promise that resolves when the place is updated.
   */
  async updatePlace(place: Place): Promise<void> {
    return this.datasouce.updatePlace(place);
  }
}
