use Symfony\Component\RemoteEvent\Event\Mailer\AbstractMailerEvent;
use Symfony\Component\RemoteEvent\Event\Mailer\MailerDeliveryEvent;
use Symfony\Component\RemoteEvent\Event\Mailer\MailerEngagementEvent;
use Symfony\Component\RemoteEvent\Exception\ParseException;
use Symfony\Component\RemoteEvent\PayloadConverterInterface;
final class BrevoPayloadConverter implements PayloadConverterInterface
{ public function convert(array
$payload): AbstractMailerEvent
{ if (\
in_array($payload['event'
],
['request', 'deferred', 'delivered', 'soft_bounce', 'hard_bounce', 'invalid_email', 'blocked', 'error'
], true
)) { $name =
match ($payload['event'
]) { 'request' => MailerDeliveryEvent::RECEIVED,
'deferred' => MailerDeliveryEvent::DEFERRED,
'delivered' => MailerDeliveryEvent::DELIVERED,
'soft_bounce' => MailerDeliveryEvent::BOUNCE,
'hard_bounce' => MailerDeliveryEvent::BOUNCE,
'invalid_email' => MailerDeliveryEvent::DROPPED,
'blocked' => MailerDeliveryEvent::DROPPED,
'error' => MailerDeliveryEvent::DROPPED,
};
$event =
new MailerDeliveryEvent($name,
$payload['message-id'
],
$payload);
}