package auctiora;

import lombok.With;
import java.time.Duration;
import java.time.LocalDateTime;

/**
 * Represents a lot (kavel) in an auction.
 * Data typically populated by the external scraper process.
 * This project enriches the data with image analysis and monitoring.
 */
@With
record Lot(
        int saleId,
        int lotId,
        String title,
        String description,
        String manufacturer,
        String type,
        int year,
        String category,
        double currentBid,
        String currency,
        String url,
        LocalDateTime closingTime,
        boolean closingNotified
) {
   
   public long minutesUntilClose() {
      if (closingTime == null) return Long.MAX_VALUE;
      return Duration.between(LocalDateTime.now(), closingTime).toMinutes();
   }
   public Lot withCurrentBid(double newBid) {
      return new Lot(saleId, lotId, title, description,
                     manufacturer, type, year, category,
                     newBid, currency, url, closingTime, closingNotified);
   }
   
   public Lot withClosingNotified(boolean flag) {
      return new Lot(saleId, lotId, title, description,
                     manufacturer, type, year, category,
                     currentBid, currency, url, closingTime, flag);
   }
   
}
