package io.delphiplatform.api.v3.model.datahealth;

import com.fasterxml.jackson.annotation.JsonProperty;

import java.time.LocalDate;

import io.delphiplatform.api.v3.rdb.entity.spotify.SpotifyJunoStatusDailyEntity;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@EqualsAndHashCode
@Builder
public class DspDataImportReportItem {

    @JsonProperty("report_date")
    private LocalDate reportDate;

    @JsonProperty("import_date")
    private LocalDate importDate;

    @JsonProperty("status")
    private DspDataImportDataHealthStatus status;

    public static DspDataImportReportItem from(SpotifyJunoStatusDailyEntity entity) {
        if (entity == null) {
            return null;
        }
        return DspDataImportReportItem.builder()
            .reportDate(entity.getReportDate())
            .importDate(entity.getImportDate())
            .status(entity.getStatus() == null ? null
                : DspDataImportDataHealthStatus.fromValue(entity.getStatus().getValue()))
            .build();
    }
}
