userId = $userId; $this->service = $service; } /** * Get information about upcoming events * * @param string|null $location location/URL to filter by * @return DataResponse|DataResponse * * 200: Upcoming events * 401: When not authenticated */ #[NoAdminRequired] public function getEvents(?string $location = null): DataResponse { if ($this->userId === null) { return new DataResponse(null, Http::STATUS_UNAUTHORIZED); } return new DataResponse([ 'events' => array_map(fn (UpcomingEvent $e) => $e->jsonSerialize(), $this->service->getEvents( $this->userId, $location, )), ]); } }