package pl.polskalokalnie.lead;

import java.time.Instant;
import java.util.LinkedHashSet;
import java.util.Set;

public record TargetGroupResponse(
        Long id,
        String name,
        String description,
        Set<LeadSource> sources,
        String city,
        String tag,
        LeadStatus status,
        boolean requireEmail,
        boolean requirePhone,
        boolean requireEmailConsent,
        boolean requireSmsConsent,
        long memberCount,
        Instant createdAt
) {
    public static TargetGroupResponse from(TargetGroup group, long memberCount) {
        return new TargetGroupResponse(
                group.getId(),
                group.getName(),
                group.getDescription(),
                new LinkedHashSet<>(group.getSources()),
                group.getCity(),
                group.getTag(),
                group.getStatus(),
                group.isRequireEmail(),
                group.isRequirePhone(),
                group.isRequireEmailConsent(),
                group.isRequireSmsConsent(),
                memberCount,
                group.getCreatedAt()
        );
    }
}
