protected function doParse(Request
$request, string
$secret): ?SmsEvent
{ // Statuses: https://www.twilio.com/docs/sms/api/message-resource#message-status-values
// Payload examples: https://www.twilio.com/docs/sms/outbound-message-logging
$payload =
$request->request->
all();
if ( !
isset($payload['MessageStatus'
]) || !
isset($payload['MessageSid'
]) || !
isset($payload['To'
]) ) { throw new RejectWebhookException(406, 'Payload is malformed.'
);
} $name =
match ($payload['MessageStatus'
]) { 'delivered' => SmsEvent::DELIVERED,
'failed' => SmsEvent::FAILED,
'undelivered' => SmsEvent::FAILED,
'accepted' => null,
'queued' => null,
'sending' => null,
'sent' => null,
'canceled' => null,