Skip to content

Commit a1c72ff

Browse files
committed
ISSUE-345: refactor subscription
1 parent 8d636dc commit a1c72ff

File tree

11 files changed

+231
-251
lines changed

11 files changed

+231
-251
lines changed

config/services/validators.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,3 @@ services:
1313
autowire: true
1414
autoconfigure: true
1515
tags: [ 'validator.constraint_validator' ]
16-
17-
PhpList\RestBundle\Validator\ListExistsValidator:
18-
autowire: true
19-
autoconfigure: true
20-
tags: [ 'validator.constraint_validator' ]

src/Controller/ListController.php

Lines changed: 0 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use PhpList\RestBundle\Controller\Traits\AuthenticationTrait;
1111
use PhpList\RestBundle\Entity\Request\CreateSubscriberListRequest;
1212
use PhpList\RestBundle\Serializer\SubscriberListNormalizer;
13-
use PhpList\RestBundle\Serializer\SubscriberNormalizer;
1413
use PhpList\RestBundle\Service\Manager\SubscriberListManager;
1514
use PhpList\RestBundle\Validator\RequestValidator;
1615
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
@@ -243,115 +242,6 @@ public function deleteList(
243242
return new JsonResponse(null, Response::HTTP_NO_CONTENT);
244243
}
245244

246-
#[Route('/{listId}/subscribers', name: 'get_subscriber_from_list', methods: ['GET'])]
247-
#[OA\Get(
248-
path: '/lists/{listId}/subscribers',
249-
description: 'Returns a JSON list of all subscribers for a subscriber list.',
250-
summary: 'Gets a list of all subscribers of a subscriber list.',
251-
tags: ['lists'],
252-
parameters: [
253-
new OA\Parameter(
254-
name: 'session',
255-
description: 'Session ID obtained from authentication',
256-
in: 'header',
257-
required: true,
258-
schema: new OA\Schema(type: 'string')
259-
),
260-
new OA\Parameter(
261-
name: 'listId',
262-
description: 'List ID',
263-
in: 'path',
264-
required: true,
265-
schema: new OA\Schema(type: 'string')
266-
)
267-
],
268-
responses: [
269-
new OA\Response(
270-
response: 200,
271-
description: 'Success',
272-
content: new OA\JsonContent(
273-
type: 'array',
274-
items: new OA\Items(ref: '#/components/schemas/Subscriber')
275-
)
276-
),
277-
new OA\Response(
278-
response: 403,
279-
description: 'Failure',
280-
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
281-
)
282-
]
283-
)]
284-
public function getListMembers(
285-
Request $request,
286-
#[MapEntity(mapping: ['listId' => 'id'])] SubscriberList $list,
287-
SubscriberNormalizer $normalizer
288-
): JsonResponse {
289-
$this->requireAuthentication($request);
290-
291-
$subscribers = $this->subscriberListManager->getSubscriberListMembers($list);
292-
$normalized = array_map(function ($item) use ($normalizer) {
293-
return $normalizer->normalize($item);
294-
}, $subscribers);
295-
296-
return new JsonResponse($normalized, Response::HTTP_OK);
297-
}
298-
299-
#[Route('/{listId}/subscribers/count', name: 'get_subscribers_count_from_list', methods: ['GET'])]
300-
#[OA\Get(
301-
path: '/lists/{listId}/count',
302-
description: 'Returns a count of all subscribers in a given list.',
303-
summary: 'Gets the total number of subscribers of a list',
304-
tags: ['lists'],
305-
parameters: [
306-
new OA\Parameter(
307-
name: 'session',
308-
description: 'Session ID obtained from authentication',
309-
in: 'header',
310-
required: true,
311-
schema: new OA\Schema(type: 'string')
312-
),
313-
new OA\Parameter(
314-
name: 'listId',
315-
description: 'List ID',
316-
in: 'path',
317-
required: true,
318-
schema: new OA\Schema(type: 'string')
319-
)
320-
],
321-
responses: [
322-
new OA\Response(
323-
response: 200,
324-
description: 'Success',
325-
content: new OA\JsonContent(
326-
properties: [
327-
new OA\Property(
328-
property: 'subscribers_count',
329-
type: 'integer',
330-
example: 42
331-
)
332-
],
333-
type: 'object'
334-
)
335-
),
336-
new OA\Response(
337-
response: 403,
338-
description: 'Failure',
339-
content: new OA\JsonContent(ref: '#/components/schemas/UnauthorizedResponse')
340-
)
341-
]
342-
)]
343-
public function getSubscribersCount(
344-
Request $request,
345-
#[MapEntity(mapping: ['listId' => 'id'])] SubscriberList $list
346-
): JsonResponse {
347-
$this->requireAuthentication($request);
348-
349-
return new JsonResponse(
350-
['subscribers_count' => count($list->getSubscribers())],
351-
Response::HTTP_OK,
352-
);
353-
}
354-
355245
#[Route('', name: 'create_list', methods: ['POST'])]
356246
#[OA\Post(
357247
path: '/lists',

0 commit comments

Comments
 (0)