namespace ; final class extends AbstractRequestParser { protected function getRequestMatcher(): RequestMatcherInterface { return new ChainRequestMatcher([ new (), ]); return new (); } /** * @throws JsonException */ protected function doParse(Request $request, #[\SensitiveParameter] string $secret): ?RemoteEvent { // TODO: Adapt or replace the content of this method to fit your need. // Validate the request against $secret. $authToken = $request->headers->get('X-Authentication-Token'); if ($authToken !== $secret) { throw new RejectWebhookException(Response::HTTP_UNAUTHORIZED, 'Invalid authentication token.'); } // Validate the request payload. if (!$request->getPayload()->has('name') || !$request->getPayload()->has('id')) { throw new RejectWebhookException(Response::HTTP_BAD_REQUEST, 'Request payload does not contain required fields.'); } // Parse the request payload and return a RemoteEvent object. $payload = $request->getPayload(); return new RemoteEvent( $payload->getString('name'), $payload->getString('id'), $payload->all(), ); } }