clientService = $clientService; } /** * @NoAdminRequired * @NoCSRFRequired */ public function index(int $limit = 10): JSONResponse { if (!in_array($limit, [10, 25, 50])) { return new JSONResponse('Invalid limit, can be 10, 25 or 50.', Http::STATUS_BAD_REQUEST); } try { $client = $this->clientService->newClient(); $response = $client->get("https://rss.applemarketingtools.com/api/v2/fr/podcasts/top/{$limit}/podcasts.json"); $json = json_decode($response->getBody(), flags: JSON_THROW_ON_ERROR); return new JSONResponse($json, $response->getStatusCode()); } catch (Exception $e) { return new JSONResponse($e->getMessage(), Http::STATUS_INTERNAL_SERVER_ERROR); } } }