package pl.polskalokalnie.listing;

import java.math.BigDecimal;
import java.time.Instant;

/**
 * Lekka reprezentacja ogloszenia do list (Kupuje/Wynajmuje, moderacja, moje ogloszenia).
 * Nie zawiera pelnej galerii ani pol szczegolowych - od tego jest {@link ListingDetailResponse}.
 */
public record ListingResponse(
        Long id,
        String title,
        String description,
        OfferType offerType,
        PropertyType propertyType,
        String city,
        String district,
        String address,
        BigDecimal price,
        Double area,
        Integer rooms,
        String floor,
        String buildingFloors,
        String market,
        Integer yearBuilt,
        String coverPhoto,
        String ownerEmail,
        ListingStatus status,
        Instant createdAt
) {
    public static ListingResponse from(PropertyListing listing) {
        return new ListingResponse(
                listing.getId(),
                listing.getTitle(),
                listing.getDescription(),
                listing.getOfferType(),
                listing.getPropertyType(),
                listing.getCity(),
                listing.getDistrict(),
                listing.getAddress(),
                listing.getPrice(),
                listing.getArea(),
                listing.getRooms(),
                listing.getFloor(),
                listing.getBuildingFloors(),
                listing.getMarket(),
                listing.getYearBuilt(),
                listing.getCoverPhoto(),
                listing.getOwnerEmail(),
                listing.getStatus(),
                listing.getCreatedAt()
        );
    }
}
