feat: MailJet list handling with DOI, webhook receiver and API endpoint
addresses #869cut134
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
class NewsletterSubscriptionRequest
|
||||
{
|
||||
#[Assert\NotBlank]
|
||||
#[Assert\Email(mode: 'strict')]
|
||||
public ?string $email = null;
|
||||
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $firstName = null;
|
||||
|
||||
#[Assert\Length(max: 255)]
|
||||
public ?string $lastName = null;
|
||||
|
||||
/**
|
||||
* @var list<int>
|
||||
*/
|
||||
#[Assert\NotNull]
|
||||
#[Assert\Type('array')]
|
||||
#[Assert\Count(min: 1)]
|
||||
#[Assert\All([
|
||||
new Assert\Type('integer'),
|
||||
new Assert\Positive(),
|
||||
])]
|
||||
public array $listIds = [];
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
class NewsletterSubscriptionRequestResult
|
||||
{
|
||||
public const STATE_SUBSCRIBED = 'subscribed';
|
||||
public const STATE_PENDING_CONFIRMATION = 'pending_confirmation';
|
||||
public const STATE_CONFIRMATION_REQUESTED = 'confirmation_requested';
|
||||
public const LIST_STATE_PENDING = 'pending';
|
||||
public const LIST_STATE_ALREADY_REGISTERED = 'already_registered';
|
||||
public const LIST_STATE_SUCCESS = 'success';
|
||||
|
||||
/**
|
||||
* @param list<int> $listIds
|
||||
* @param array<int, string> $listStates
|
||||
*/
|
||||
public function __construct(
|
||||
public readonly string $email,
|
||||
public readonly array $listIds,
|
||||
public readonly string $state,
|
||||
public readonly bool $confirmationRequested,
|
||||
public readonly array $listStates = [],
|
||||
) {
|
||||
}
|
||||
|
||||
public function stateForList(int $listId): string
|
||||
{
|
||||
return $this->listStates[$listId] ?? match ($this->state) {
|
||||
self::STATE_SUBSCRIBED => self::LIST_STATE_SUCCESS,
|
||||
default => self::LIST_STATE_PENDING,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user