$event =
new MailerDeliveryEvent($name,
$payload['MessageID'
],
$payload);
$event->
setReason($payload['Description'
] ?? ''
);
} else { $name =
match ($payload['RecordType'
]) { 'Click' => MailerEngagementEvent::CLICK,
'SubscriptionChange' => MailerEngagementEvent::UNSUBSCRIBE,
'Open' => MailerEngagementEvent::OPEN,
'SpamComplaint' => MailerEngagementEvent::SPAM,
default =>
throw new ParseException(sprintf('Unsupported event "%s".',
$payload['RecordType'
])),
};
$event =
new MailerEngagementEvent($name,
$payload['MessageID'
],
$payload);
} $payloadDate =
match ($payload['RecordType'
]) { 'Delivery' =>
$payload['DeliveredAt'
],
'Bounce' =>
$payload['BouncedAt'
],
'Click' =>
$payload['ReceivedAt'
],
'SubscriptionChange' =>
$payload['ChangedAt'
],
'Open' =>
$payload['ReceivedAt'
],
'SpamComplaint' =>
$payload['BouncedAt'
],
default =>
throw new ParseException(sprintf('Unsupported event "%s".',
$payload['RecordType'
])),
};
if (!
$date = \DateTimeImmutable::
createFromFormat('Y-m-d\TH:i:sT',
$payloadDate)) {