|
5 | 5 | namespace PhpList\RestBundle\Controller;
|
6 | 6 |
|
7 | 7 | use OpenApi\Attributes as OA;
|
| 8 | +use PhpList\Core\Domain\Model\Messaging\Message; |
8 | 9 | use PhpList\Core\Security\Authentication;
|
9 | 10 | use PhpList\RestBundle\Controller\Traits\AuthenticationTrait;
|
10 | 11 | use PhpList\RestBundle\Entity\Request\CreateMessageRequest;
|
11 | 12 | use PhpList\RestBundle\Serializer\MessageNormalizer;
|
12 | 13 | use PhpList\RestBundle\Service\Manager\MessageManager;
|
13 | 14 | use PhpList\RestBundle\Service\Provider\MessageProvider;
|
14 | 15 | use PhpList\RestBundle\Validator\RequestValidator;
|
| 16 | +use Symfony\Bridge\Doctrine\Attribute\MapEntity; |
15 | 17 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
16 | 18 | use Symfony\Component\HttpFoundation\JsonResponse;
|
17 | 19 | use Symfony\Component\HttpFoundation\Request;
|
@@ -92,6 +94,45 @@ public function getMessages(Request $request): JsonResponse
|
92 | 94 | return new JsonResponse($normalized, Response::HTTP_OK);
|
93 | 95 | }
|
94 | 96 |
|
| 97 | + #[Route('/{messageId}', name: 'get_campaign', methods: ['GET'])] |
| 98 | + #[OA\Get( |
| 99 | + path: '/campaigns/{messageId}', |
| 100 | + description: 'Returns campaign/message by id.', |
| 101 | + summary: 'Gets a campaign by id.', |
| 102 | + tags: ['campaigns'], |
| 103 | + parameters: [ |
| 104 | + new OA\Parameter( |
| 105 | + name: 'session', |
| 106 | + description: 'Session ID obtained from authentication', |
| 107 | + in: 'header', |
| 108 | + required: true, |
| 109 | + schema: new OA\Schema( |
| 110 | + type: 'string' |
| 111 | + ) |
| 112 | + ) |
| 113 | + ], |
| 114 | + responses: [ |
| 115 | + new OA\Response( |
| 116 | + response: 200, |
| 117 | + description: 'Success', |
| 118 | + content: new OA\JsonContent(ref: '#/components/schemas/Message') |
| 119 | + ), |
| 120 | + new OA\Response( |
| 121 | + response: 403, |
| 122 | + description: 'Failure', |
| 123 | + content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse') |
| 124 | + ) |
| 125 | + ] |
| 126 | + )] |
| 127 | + public function getMessage( |
| 128 | + Request $request, |
| 129 | + #[MapEntity(mapping: ['messageId' => 'id'])] Message $message |
| 130 | + ): JsonResponse { |
| 131 | + $this->requireAuthentication($request); |
| 132 | + |
| 133 | + return new JsonResponse($this->normalizer->normalize($message), Response::HTTP_OK); |
| 134 | + } |
| 135 | + |
95 | 136 | #[Route('', name: 'create_message', methods: ['POST'])]
|
96 | 137 | #[OA\Post(
|
97 | 138 | path: '/campaigns',
|
|
0 commit comments