<?php

declare(strict_types=1);

/*
 * This file is part of the Ferienpass package.
 *
 * (c) Richard Henkenjohann <richard@ferienpass.online>
 *
 * For more information visit the project website <https://ferienpass.online>
 * or the documentation under <https://docs.ferienpass.online>.
 */

namespace Ferienpass\CoreBundle\Message;

use Ferienpass\CoreBundle\Entity\Edition;
use Ferienpass\CoreBundle\Entity\Offer\OfferInterface;
use Ferienpass\CoreBundle\Entity\User;

class DispatchMailing implements LoggableMessageInterface
{
    /**
     * @param array<string> $offerIds
     * @param array<string> $editionIds
     */
    public function __construct(private readonly ?string $invokingUserId, private readonly array $emails, private readonly string $subject, private readonly string $content, private readonly array $context, private readonly array $attachments = [], private readonly bool $withPaymentLink = false, private readonly array $offerIds = [], private readonly array $editionIds = [], private readonly MailingCopyMode $copyMode = MailingCopyMode::None)
    {
    }

    public function getInvokingUserId(): ?string
    {
        return $this->invokingUserId;
    }

    public function getEmails(): array
    {
        return $this->emails;
    }

    public function getSubject(): string
    {
        return $this->subject;
    }

    public function getContent(): string
    {
        return $this->content;
    }

    public function getContext(): array
    {
        return $this->context;
    }

    public function getAttachments(): array
    {
        return $this->attachments;
    }

    public function isWithPaymentLink(): bool
    {
        return $this->withPaymentLink;
    }

    /**
     * How the invoking user is copied in on the mailing (none, a single
     * non-personalized copy, or BCC on every message) — always delivered to
     * their current email address.
     */
    public function getCopyMode(): MailingCopyMode
    {
        return $this->copyMode;
    }

    public function getRelated(): array
    {
        return array_filter([
            User::class => $this->invokingUserId,
            OfferInterface::class => $this->offerIds,
            Edition::class => $this->editionIds,
        ]);
    }
}
