Skip to content

Commit 0be0383

Browse files
committed
Add public page to return list data
1 parent f03fe55 commit 0be0383

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

src/Subscription/Controller/SubscribePageController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ className: SubscribePage::class,
122122
name: 'php-auth-pw',
123123
description: 'Session key obtained from login',
124124
in: 'header',
125-
required: true,
125+
required: false,
126126
schema: new OA\Schema(type: 'string')
127127
),
128128
new OA\Parameter(

src/Subscription/Controller/SubscriberListController.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,59 @@ public function getList(
181181
return $this->json($this->normalizer->normalize($list), Response::HTTP_OK);
182182
}
183183

184+
#[Route('/{listId}/public', name: 'get_one_public', requirements: ['listId' => '\d+'], methods: ['GET'])]
185+
#[OA\Get(
186+
path: '/api/v2/lists/{listId}/public',
187+
description: '🚧 **Status: Beta** – This method is under development. Avoid using in production. ' .
188+
'Returns a single subscriber list with specified ID.',
189+
summary: 'Gets a subscriber list.',
190+
tags: ['lists'],
191+
parameters: [
192+
new OA\Parameter(
193+
name: 'listId',
194+
description: 'List ID',
195+
in: 'path',
196+
required: true,
197+
schema: new OA\Schema(type: 'string')
198+
),
199+
],
200+
responses: [
201+
new OA\Response(
202+
response: 200,
203+
description: 'Success',
204+
content: [
205+
206+
]
207+
),
208+
new OA\Response(
209+
response: 404,
210+
description: 'Failure',
211+
content: new OA\JsonContent(
212+
properties: [
213+
new OA\Property(
214+
property: 'message',
215+
type: 'string',
216+
example: 'There is no list with that ID.'
217+
)
218+
],
219+
type: 'object'
220+
)
221+
),
222+
]
223+
)]
224+
public function getPublicList(#[MapEntity(mapping: ['listId' => 'id'])] ?SubscriberList $list = null): JsonResponse
225+
{
226+
if (!$list) {
227+
throw $this->createNotFoundException('Subscriber list not found.');
228+
}
229+
230+
return $this->json([
231+
'id' => $list->getId(),
232+
'name' => $list->getName(),
233+
'description' => $list->getDescription(),
234+
], Response::HTTP_OK);
235+
}
236+
184237
#[Route('/{listId}', name: 'delete', requirements: ['listId' => '\d+'], methods: ['DELETE'])]
185238
#[OA\Delete(
186239
path: '/api/v2/lists/{listId}',

0 commit comments

Comments
 (0)