Skip to content

Commit 92c9ba2

Browse files
committed
ISSUE-344: api doc
1 parent d93647d commit 92c9ba2

File tree

5 files changed

+11
-70
lines changed

5 files changed

+11
-70
lines changed

composer.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"require": {
3333
"php": "^8.1",
34-
"phplist/core": "dev-ISSUE-337",
34+
"phplist/core": "5.0.0-alpha1",
3535
"friendsofsymfony/rest-bundle": "*",
3636
"symfony/test-pack": "^1.0",
3737
"symfony/process": "^6.4",
@@ -85,9 +85,6 @@
8585
]
8686
},
8787
"extra": {
88-
"branch-alias": {
89-
"dev-ISSUE-337": "5.0.x-dev"
90-
},
9188
"symfony-app-dir": "bin",
9289
"symfony-bin-dir": "bin",
9390
"symfony-var-dir": "var",

docs/.gitkeep

Whitespace-only changes.

openapi.yaml

-55
This file was deleted.

src/Controller/ListController.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,11 @@ public function deleteList(
267267
return new JsonResponse(null, Response::HTTP_NO_CONTENT, [], false);
268268
}
269269

270-
#[Route('/lists/{id}/members', name: 'get_subscriber_from_list', methods: ['GET'])]
270+
#[Route('/lists/{id}/subscribers', name: 'get_subscriber_from_list', methods: ['GET'])]
271271
#[OA\Get(
272-
path: '/lists/{list}/members',
272+
path: '/lists/{list}/subscribers',
273273
description: 'Returns a JSON list of all subscribers for a subscriber list.',
274-
summary: 'Gets a list of all subscribers (members) of a subscriber list.',
274+
summary: 'Gets a list of all subscribers of a subscriber list.',
275275
tags: ['lists'],
276276
parameters: [
277277
new OA\Parameter(

src/Controller/SubscriberController.php

+7-8
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function __construct(
3939

4040
#[Route('/subscribers', name: 'create_subscriber', methods: ['POST'])]
4141
#[OA\Post(
42-
path: '/subscriber',
42+
path: '/subscribers',
4343
description: 'Creates a new subscriber (if there is no subscriber with the given email address yet).',
4444
summary: 'Create a subscriber',
4545
requestBody: new OA\RequestBody(
@@ -49,10 +49,8 @@ public function __construct(
4949
required: ['email'],
5050
properties: [
5151
new OA\Property(property: 'email', type: 'string', format: 'string', example: '[email protected]'),
52-
new OA\Property(property: 'confirmed', type: 'boolean', example: false),
53-
new OA\Property(property: 'blacklisted', type: 'boolean', example: false),
52+
new OA\Property(property: 'request_confirmation', type: 'boolean', example: false),
5453
new OA\Property(property: 'html_email', type: 'boolean', example: false),
55-
new OA\Property(property: 'disabled', type: 'boolean', example: false)
5654
]
5755
)
5856
),
@@ -140,13 +138,14 @@ public function postAction(Request $request, SerializerInterface $serializer): J
140138
if ($this->subscriberRepository->findOneByEmail($email) !== null) {
141139
throw new ConflictHttpException('This resource already exists.', null, 1513439108);
142140
}
141+
$confirmed = (bool)$data->get('request_confirmation', true);
143142
// @phpstan-ignore-next-line
144143
$subscriber = new Subscriber();
145144
$subscriber->setEmail($email);
146-
$subscriber->setConfirmed((bool)$data->get('confirmed', false));
147-
$subscriber->setBlacklisted((bool)$data->get('blacklisted', false));
145+
$subscriber->setConfirmed(!$confirmed);
146+
$subscriber->setBlacklisted(false);
148147
$subscriber->setHtmlEmail((bool)$data->get('html_email', true));
149-
$subscriber->setDisabled((bool)$data->get('disabled', false));
148+
$subscriber->setDisabled(false);
150149

151150
$this->subscriberRepository->save($subscriber);
152151

@@ -173,7 +172,7 @@ private function validateSubscriber(Request $request): void
173172
$invalidFields[] = 'email';
174173
}
175174

176-
$booleanFields = ['confirmed', 'blacklisted', 'html_email', 'disabled'];
175+
$booleanFields = ['request_confirmation', 'html_email'];
177176
foreach ($booleanFields as $fieldKey) {
178177
if ($request->getPayload()->get($fieldKey) !== null
179178
&& !is_bool($request->getPayload()->get($fieldKey))

0 commit comments

Comments
 (0)