$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);
} else { $name =
match ($payload['event'
]) { 'click' => MailerEngagementEvent::CLICK,
'unsubscribed' => MailerEngagementEvent::UNSUBSCRIBE,
'unique_opened' => MailerEngagementEvent::OPEN,
'opened' => MailerEngagementEvent::OPEN,
'proxy_open' => MailerEngagementEvent::OPEN,
'complaint' => MailerEngagementEvent::SPAM,
default =>
throw new ParseException(sprintf('Unsupported event "%s".',
$payload['event'
])),
};
$event =
new MailerEngagementEvent($name,
$payload['message-id'
],
$payload);
}