package fr.titionfire.ffsaf.rest.data;

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

import java.util.HashMap;
import java.util.Map;

@Data
@Builder
@ToString
@AllArgsConstructor
@RegisterForReflection
public class SimpleClub {
    @Schema(description = "L'identifiant unique du club.", example = "1")
    private Long id;
    @Schema(description = "Identifiant long du club (UUID)", example = "b94f3167-3f6a-449c-a73b-ec84202bf07e")
    private String clubId;
    @Schema(description = "Le nom du club.", example = "Association sportive")
    private String name;
    @Schema(description = "Le pays du club.", example = "FR")
    private String country;
    @Schema(description = "Les contacts du club", example = "{\"SITE\": \"www.test.com\", \"COURRIEL\": \"test@test.com\"}")
    private Map<Contact, String> contact;
    @Schema(description = "Liste des lieux d'entraînement", example = "[{\"text\":\"addr 1\",\"lng\":2.24654,\"lat\":52.4868658},{\"text\":\"addr 2\",\"lng\":2.88654,\"lat\":52.7865456}]")
    private String training_location;
    @Schema(description = "Liste des jours et horaires d'entraînement (jours 0-6, 0=>lundi) (temps en minute depuis 00:00, 122=>2h02)", example = "[{\"day\":0,\"time_start\":164,\"time_end\":240},{\"day\":3,\"time_start\":124,\"time_end\":250}]")
    private String training_day_time;
    @Schema(description = "Contact interne du club", example = "john.doe@test.com")
    private String contact_intern;
    @Schema(description = "Adresse postale du club", example = "1 rue de l'exemple, 75000 Paris")
    private String address;
    @Schema(description = "Numéro SIRET ou RNA du club", example = "12345678901234")
    private String state_id;
    @Schema(description = "Numéro d'affiliation du club", example = "12345")
    private Long no_affiliation;
    @Schema(description = "Club international", example = "false")
    private boolean international;
    @Schema(description = "Une map contenant les contacts possible pout un club.")
    private HashMap<String, String> contactMap = null;

    public static SimpleClub fromModel(ClubModel model) {
        if (model == null)
            return null;

        return new SimpleClubBuilder()
                .id(model.getId())
                .clubId(model.getClubId())
                .name(model.getName())
                .country(model.getCountry())
                .contact(model.getContact())
                .training_location(model.getTraining_location())
                .training_day_time(model.getTraining_day_time())
                .contact_intern(model.getContact_intern())
                .state_id(model.getStateId())
                .no_affiliation(model.getNo_affiliation())
                .international(model.isInternational())
                .address(model.getAddress())
                .build();
    }
}
