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 ),
2633 new OA \Property (property: 'unique_id ' , type: 'string ' , example: '69f4e92cf50eafca9627f35704f030f4 ' ),
34+ new OA \Property (property: 'uuid ' , type: 'string ' , example: '69f4e92-cf50eaf-ca9627f-35704f-030f4 ' ),
2735 new OA \Property (property: 'html_email ' , type: 'boolean ' , example: true ),
2836 new OA \Property (property: 'disabled ' , type: 'boolean ' , example: false ),
2937 new OA \Property (
3038 property: 'subscribed_lists ' ,
3139 type: 'array ' ,
3240 items: new OA \Items (ref: '#/components/schemas/SubscriberList ' )
3341 ),
42+ new OA \Property (
43+ property: 'history ' ,
44+ type: 'array ' ,
45+ items: new OA \Items (ref: '#/components/schemas/SubscriberHistory ' )
46+ ),
3447 ],
3548 type: 'object '
3649)]
3750class SubscriberNormalizer implements NormalizerInterface
3851{
39- public function __construct (private readonly SubscriberListNormalizer $ subscriberListNormalizer )
40- {
52+ public function __construct (
53+ private readonly SubscriberListNormalizer $ subscriberListNormalizer ,
54+ private readonly SubscriberHistoryNormalizer $ subscriberHistoryNormalizer ,
55+ ) {
4156 }
4257
4358 /**
@@ -53,15 +68,20 @@ public function normalize($object, string $format = null, array $context = []):
5368 'id ' => $ object ->getId (),
5469 'email ' => $ object ->getEmail (),
5570 'created_at ' => $ object ->getCreatedAt ()->format ('Y-m-d\TH:i:sP ' ),
71+ 'updated_at ' => $ object ->getUpdatedAt ()->format ('Y-m-d\TH:i:sP ' ),
5672 'confirmed ' => $ object ->isConfirmed (),
5773 'blacklisted ' => $ object ->isBlacklisted (),
5874 'bounce_count ' => $ object ->getBounceCount (),
5975 'unique_id ' => $ object ->getUniqueId (),
76+ 'uuid ' => $ object ->getUuid (),
6077 'html_email ' => $ object ->hasHtmlEmail (),
6178 'disabled ' => $ object ->isDisabled (),
6279 'subscribed_lists ' => array_map (function (Subscription $ subscription ) {
6380 return $ this ->subscriberListNormalizer ->normalize ($ subscription ->getSubscriberList ());
6481 }, $ object ->getSubscriptions ()->toArray ()),
82+ 'history ' => array_map (function (SubscriberHistory $ history ) {
83+ return $ this ->subscriberHistoryNormalizer ->normalize ($ history );
84+ }, $ object ->getHistory ()),
6585 ];
6686 }
6787
0 commit comments