userPreference = $userPreference; $this->userId = $UserId; } /** * @NoAdminRequired * * @param string $id * @return JSONResponse */ #[TrapError] public function show(string $id): JSONResponse { return new JSONResponse([ 'value' => $this->userPreference->getPreference($this->userId, $id) ]); } /** * @NoAdminRequired * * @param string $key * @param string $value * @return JSONResponse * @throws ClientException */ #[TrapError] public function update($key, $value): JSONResponse { if (is_null($key) || is_null($value)) { throw new ClientException('key or value missing'); } $newValue = $this->userPreference->setPreference($this->userId, $key, $value); return new JSONResponse([ 'value' => $newValue, ]); } }