|
30 | 30 | use Symfony\Component\HttpFoundation\JsonResponse; |
31 | 31 | use Symfony\Component\HttpFoundation\Request; |
32 | 32 | use Symfony\Component\HttpFoundation\Response; |
| 33 | +use Symfony\Component\Routing\Attribute\Route; |
33 | 34 |
|
34 | 35 | final class FaqController extends AbstractApiController |
35 | 36 | { |
@@ -71,6 +72,7 @@ final class FaqController extends AbstractApiController |
71 | 72 | ]', |
72 | 73 | ))] |
73 | 74 | #[OA\Response(response: 404, description: 'If the category has no FAQs.', content: new OA\JsonContent(example: []))] |
| 75 | + #[Route(path: 'v3.2/faqs/{categoryId}', name: 'api.faqs.by-category-id', methods: ['GET'])] |
74 | 76 | public function getByCategoryId(Request $request): JsonResponse |
75 | 77 | { |
76 | 78 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -143,6 +145,7 @@ public function getByCategoryId(Request $request): JsonResponse |
143 | 145 | description: 'If there are no FAQs for the given FAQ ID.', |
144 | 146 | content: new OA\JsonContent(example: []), |
145 | 147 | )] |
| 148 | + #[Route(path: 'v3.2/faq/{categoryId}/{faqId}', name: 'api.faq.by-id', methods: ['GET'])] |
146 | 149 | public function getById(Request $request): JsonResponse |
147 | 150 | { |
148 | 151 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -208,6 +211,7 @@ public function getById(Request $request): JsonResponse |
208 | 211 | ]', |
209 | 212 | ))] |
210 | 213 | #[OA\Response(response: 404, description: 'If the tag ID has no FAQs.', content: new OA\JsonContent(example: []))] |
| 214 | + #[Route(path: 'v3.2/faqs/tags/{tagId}', name: 'api.faqs.by-tag-id', methods: ['GET'])] |
211 | 215 | public function getByTagId(Request $request): JsonResponse |
212 | 216 | { |
213 | 217 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -259,6 +263,7 @@ public function getByTagId(Request $request): JsonResponse |
259 | 263 | description: "If there's not a single popular FAQ.", |
260 | 264 | content: new OA\JsonContent(example: []), |
261 | 265 | )] |
| 266 | + #[Route(path: 'v3.2/faqs/popular', name: 'api.faqs.popular', methods: ['GET'])] |
262 | 267 | public function getPopular(): JsonResponse |
263 | 268 | { |
264 | 269 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -307,6 +312,7 @@ public function getPopular(): JsonResponse |
307 | 312 | description: "If there's not one latest FAQ.", |
308 | 313 | content: new OA\JsonContent(example: []), |
309 | 314 | )] |
| 315 | + #[Route(path: 'v3.2/faqs/latest', name: 'api.faqs.latest', methods: ['GET'])] |
310 | 316 | public function getLatest(): JsonResponse |
311 | 317 | { |
312 | 318 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -354,6 +360,7 @@ public function getLatest(): JsonResponse |
354 | 360 | description: "If there's not a single trending FAQ.", |
355 | 361 | content: new OA\JsonContent(example: []), |
356 | 362 | )] |
| 363 | + #[Route(path: 'v3.2/faqs/trending', name: 'api.faqs.trending', methods: ['GET'])] |
357 | 364 | public function getTrending(): JsonResponse |
358 | 365 | { |
359 | 366 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -406,6 +413,7 @@ public function getTrending(): JsonResponse |
406 | 413 | description: "If there's not one sticky FAQ.", |
407 | 414 | content: new OA\JsonContent(example: []), |
408 | 415 | )] |
| 416 | + #[Route(path: 'v3.2/faqs/sticky', name: 'api.faqs.sticky', methods: ['GET'])] |
409 | 417 | public function getSticky(): JsonResponse |
410 | 418 | { |
411 | 419 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -522,6 +530,7 @@ enum: ['id', 'title', 'author', 'updated', 'created'], |
522 | 530 | } |
523 | 531 | }', |
524 | 532 | ))] |
| 533 | + #[Route(path: 'v3.2/faqs', name: 'api.faqs.list', methods: ['GET'])] |
525 | 534 | public function list(): JsonResponse |
526 | 535 | { |
527 | 536 | [$currentUser, $currentGroups] = CurrentUser::getCurrentUserGroupId($this->currentUser); |
@@ -658,6 +667,7 @@ public function list(): JsonResponse |
658 | 667 | content: new OA\JsonContent(example: '{ "stored": false, "error": "The given category name was not found" }'), |
659 | 668 | )] |
660 | 669 | #[OA\Response(response: 401, description: 'If the user is not authenticated.')] |
| 670 | + #[Route(path: 'v3.2/faq/create', name: 'api.faq.create', methods: ['POST'])] |
661 | 671 | public function create(Request $request): JsonResponse |
662 | 672 | { |
663 | 673 | $this->hasValidToken(); |
@@ -693,7 +703,7 @@ public function create(Request $request): JsonResponse |
693 | 703 | $isActive = Filter::filterVar($data->{'is-active'}, FILTER_VALIDATE_BOOLEAN); |
694 | 704 | $isSticky = Filter::filterVar($data->{'is-sticky'}, FILTER_VALIDATE_BOOLEAN); |
695 | 705 |
|
696 | | - // Check if category name can be mapped |
| 706 | + // Check if the category name can be mapped |
697 | 707 | if (!is_null($categoryName)) { |
698 | 708 | $categoryIdFound = $category->getCategoryIdFromName($categoryName); |
699 | 709 | if ($categoryIdFound === false) { |
@@ -816,6 +826,7 @@ public function create(Request $request): JsonResponse |
816 | 826 | ), |
817 | 827 | )] |
818 | 828 | #[OA\Response(response: 401, description: 'If the user is not authenticated.')] |
| 829 | + #[Route(path: 'v3.2/faq/update', name: 'api.faq.update', methods: ['PUT'])] |
819 | 830 | public function update(Request $request): JsonResponse |
820 | 831 | { |
821 | 832 | $this->hasValidToken(); |
|
0 commit comments