use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestMatcher\MethodRequestMatcher;
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
use Symfony\Component\RemoteEvent\Event\Sms\SmsEvent;
use Symfony\Component\Webhook\Client\AbstractRequestParser;
use Symfony\Component\Webhook\Exception\RejectWebhookException;
final class TwilioRequestParser extends AbstractRequestParser
{ protected function getRequestMatcher(): RequestMatcherInterface
{ return new MethodRequestMatcher('POST'
);
} 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'
]) )