package fr.titionfire.ffsaf.rest.data;

import fr.titionfire.ffsaf.data.model.LicenceModel;
import io.quarkus.runtime.annotations.RegisterForReflection;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import org.eclipse.microprofile.openapi.annotations.media.Schema;

@Data
@Builder
@AllArgsConstructor
@RegisterForReflection
public class SimpleLicence {
    @Schema(description = "ID de la licence", example = "1")
    Long id;
    @Schema(description = "ID du membre", example = "1")
    Long membre;
    @Schema(description = "Saison de la licence", example = "2024")
    int saison;
    @Schema(description = "Nom du médecin sur certificat médical.", example = "M. Jean")
    String certificate;
    @Schema(description = "Validation de la licence", example = "true")
    boolean validate;
    @Schema(description = "Licence payer", example = "true")
    boolean pay;

    public static SimpleLicence fromModel(LicenceModel model) {
        if (model == null)
            return null;

        return new SimpleLicenceBuilder()
                .id(model.getId())
                .membre(model.getMembre().getId())
                .saison(model.getSaison())
                .certificate(model.getCertificate())
                .validate(model.isValidate())
                .pay(model.isPay())
                .build();
    }
}
