package ba.unsa.etf.si.bbqms.ws.models;

import ba.unsa.etf.si.bbqms.domain.Advertisement;
import ba.unsa.etf.si.bbqms.domain.AdvertisementMediaType;

import java.time.Instant;

public record AdvertisementDto(
        long id,
        String title,
        AdvertisementMediaType mediaType,
        String fileName,
        String contentType,
        String mediaUrl,
        int sortOrder,
        boolean active,
        int durationSeconds,
        Instant createdAt
) {
    public static AdvertisementDto fromEntity(final Advertisement advertisement) {
        return new AdvertisementDto(
                advertisement.getId(),
                advertisement.getTitle(),
                advertisement.getMediaType(),
                advertisement.getFileName(),
                advertisement.getContentType(),
                "/api/v1/ads/media/" + advertisement.getId(),
                advertisement.getSortOrder(),
                advertisement.isActive(),
                advertisement.getDurationSeconds(),
                advertisement.getCreatedAt()
        );
    }
}
