package pl.polskalokalnie.campaign;

import java.time.Instant;

public record CampaignResponse(
        Long id,
        String name,
        Channel channel,
        String subject,
        String body,
        Long targetGroupId,
        Instant scheduledAt,
        Integer dailyLimit,
        CampaignStatus status,
        Integer sentToday,
        Instant createdAt,
        String createdBy,
        long totalRecipients,
        long sentCount
) {
    public static CampaignResponse from(Campaign campaign, long totalRecipients, long sentCount) {
        return new CampaignResponse(
                campaign.getId(),
                campaign.getName(),
                campaign.getChannel(),
                campaign.getSubject(),
                campaign.getBody(),
                campaign.getTargetGroupId(),
                campaign.getScheduledAt(),
                campaign.getDailyLimit(),
                campaign.getStatus(),
                campaign.getSentToday(),
                campaign.getCreatedAt(),
                campaign.getCreatedBy(),
                totalRecipients,
                sentCount
        );
    }
}
