Skip to content

Commit 65921b7

Browse files
committed
Update: remove ids from update dtos
1 parent e4d4b0a commit 65921b7

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

src/Common/Validator/RequestValidator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ public function validate(Request $request, string $dtoClass): RequestInterface
2929
}
3030
$routeParams = $request->attributes->get('_route_params') ?? [];
3131

32-
if (isset($routeParams['subscriberId'])) {
33-
$routeParams['subscriberId'] = (int) $routeParams['subscriberId'];
34-
}
35-
if (isset($routeParams['messageId'])) {
36-
$routeParams['messageId'] = (int) $routeParams['messageId'];
37-
}
3832
if (isset($routeParams['listId'])) {
3933
$routeParams['listId'] = (int) $routeParams['listId'];
4034
}

src/Messaging/Controller/CampaignController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,21 @@ public function getMessages(Request $request): JsonResponse
144144
response: 403,
145145
description: 'Failure',
146146
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
147+
),
148+
new OA\Response(
149+
response: 404,
150+
description: 'Failure',
151+
content: new OA\JsonContent(ref: '#/components/schemas/NotFoundErrorResponse')
147152
)
148153
]
149154
)]
150155
public function getMessage(
151156
Request $request,
152157
#[MapEntity(mapping: ['messageId' => 'id'])] ?Message $message = null
153158
): JsonResponse {
159+
if ($message === null) {
160+
throw $this->createNotFoundException('Campaign not found.');
161+
}
154162
$this->requireAuthentication($request);
155163

156164
return $this->json($this->campaignService->getMessage($message), Response::HTTP_OK);
@@ -271,6 +279,11 @@ public function createMessage(Request $request): JsonResponse
271279
description: 'Failure',
272280
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
273281
),
282+
new OA\Response(
283+
response: 404,
284+
description: 'Failure',
285+
content: new OA\JsonContent(ref: '#/components/schemas/NotFoundErrorResponse')
286+
),
274287
new OA\Response(
275288
response: 422,
276289
description: 'Failure',
@@ -282,6 +295,9 @@ public function updateMessage(
282295
Request $request,
283296
#[MapEntity(mapping: ['messageId' => 'id'])] ?Message $message = null,
284297
): JsonResponse {
298+
if ($message === null) {
299+
throw $this->createNotFoundException('Campaign not found.');
300+
}
285301
$authUser = $this->requireAuthentication($request);
286302

287303
/** @var UpdateMessageRequest $updateMessageRequest */

src/Messaging/Request/UpdateMessageRequest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,9 @@
99

1010
class UpdateMessageRequest extends CreateMessageRequest
1111
{
12-
public int $messageId;
13-
1412
public function getDto(): MessageDtoInterface
1513
{
1614
return new UpdateMessageDto(
17-
messageId: $this->messageId,
1815
content: $this->content->getDto(),
1916
format: $this->format->getDto(),
2017
metadata: $this->metadata->getDto(),

src/Subscription/Controller/SubscriberController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function updateSubscriber(
169169
}
170170
/** @var UpdateSubscriberRequest $updateSubscriberRequest */
171171
$updateSubscriberRequest = $this->validator->validate($request, UpdateSubscriberRequest::class);
172-
$subscriber = $this->subscriberManager->updateSubscriber($updateSubscriberRequest->getDto(), $admin);
172+
$subscriber = $this->subscriberManager->updateSubscriber($subscriber, $updateSubscriberRequest->getDto(), $admin);
173173
$this->entityManager->flush();
174174
$subscriberData = $this->subscriberNormalizer->normalize($subscriber, 'json');
175175

0 commit comments

Comments
 (0)