66
77use OpenApi \Attributes as OA ;
88use PhpList \Core \Domain \Subscription \Model \Subscriber ;
9+ use PhpList \Core \Domain \Subscription \Model \SubscriberHistory ;
910use PhpList \Core \Domain \Subscription \Model \Subscription ;
1011use Symfony \Component \Serializer \Normalizer \NormalizerInterface ;
1112
2021 format: 'date-time ' ,
2122 example: '2023-01-01T12:00:00Z ' ,
2223 ),
24+ new OA \Property (
25+ property: 'updated_at ' ,
26+ type: 'string ' ,
27+ format: 'date-time ' ,
28+ example: '2026-01-01T12:00:00Z ' ,
29+ ),
2330 new OA \Property (property: 'confirmed ' , type: 'boolean ' , example: true ),
2431 new OA \Property (property: 'blacklisted ' , type: 'boolean ' , example: false ),
2532 new OA \Property (property: 'bounce_count ' , type: 'integer ' , example: 0 ),
3138 type: 'array ' ,
3239 items: new OA \Items (ref: '#/components/schemas/SubscriberList ' )
3340 ),
41+ new OA \Property (
42+ property: 'history ' ,
43+ type: 'array ' ,
44+ items: new OA \Items (ref: '#/components/schemas/SubscriberHistory ' )
45+ ),
3446 ],
3547 type: 'object '
3648)]
3749class SubscriberNormalizer implements NormalizerInterface
3850{
39- public function __construct (private readonly SubscriberListNormalizer $ subscriberListNormalizer )
40- {
51+ public function __construct (
52+ private readonly SubscriberListNormalizer $ subscriberListNormalizer ,
53+ private readonly SubscriberHistoryNormalizer $ subscriberHistoryNormalizer ,
54+ ) {
4155 }
4256
4357 /**
@@ -53,6 +67,7 @@ public function normalize($object, string $format = null, array $context = []):
5367 'id ' => $ object ->getId (),
5468 'email ' => $ object ->getEmail (),
5569 'created_at ' => $ object ->getCreatedAt ()->format ('Y-m-d\TH:i:sP ' ),
70+ 'updated_at ' => $ object ->getUpdatedAt ()->format ('Y-m-d\TH:i:sP ' ),
5671 'confirmed ' => $ object ->isConfirmed (),
5772 'blacklisted ' => $ object ->isBlacklisted (),
5873 'bounce_count ' => $ object ->getBounceCount (),
@@ -62,6 +77,9 @@ public function normalize($object, string $format = null, array $context = []):
6277 'subscribed_lists ' => array_map (function (Subscription $ subscription ) {
6378 return $ this ->subscriberListNormalizer ->normalize ($ subscription ->getSubscriberList ());
6479 }, $ object ->getSubscriptions ()->toArray ()),
80+ 'history ' => array_map (function (SubscriberHistory $ history ) {
81+ return $ this ->subscriberHistoryNormalizer ->normalize ($ history );
82+ }, $ object ->getHistory ()),
6583 ];
6684 }
6785
0 commit comments