@@ -47,6 +47,9 @@ class Payload implements \JsonSerializable
4747 const PAYLOAD_RELEVANCE_SCORE_KEY = 'relevance-score ' ;
4848 const PAYLOAD_STALE_DATE_KEY = 'stale-date ' ;
4949 const PAYLOAD_CONTENT_STATE_KEY = 'content-state ' ;
50+ const PAYLOAD_DISMISSAL_DATE_KEY = 'dismissal-date ' ;
51+ const PAYLOAD_ATTRIBUTES_TYPE_KEY = 'attributes-type ' ;
52+ const PAYLOAD_ATTRIBUTES_KEY = 'attributes ' ;
5053
5154 const PAYLOAD_HTTP2_REGULAR_NOTIFICATION_MAXIMUM_SIZE = 4096 ;
5255 const PAYLOAD_HTTP2_VOIP_NOTIFICATION_MAXIMUM_SIZE = 5120 ;
@@ -169,6 +172,27 @@ class Payload implements \JsonSerializable
169172 */
170173 private $ contentState ;
171174
175+ /**
176+ * Attributes type
177+ *
178+ * @var string|null
179+ */
180+ private $ attributesType ;
181+
182+ /**
183+ * Attributes
184+ *
185+ * @var array
186+ */
187+ private $ attributes = [];
188+
189+ /**
190+ * Dismissal date
191+ *
192+ * @var int|null
193+ */
194+ private $ dismissalDate ;
195+
172196 protected function __construct ()
173197 {
174198 }
@@ -595,6 +619,79 @@ public function getEvent()
595619 return $ this ->event ;
596620 }
597621
622+ /**
623+ * Set attributes type for Payload.
624+ * This is used to specify the interpreter of the attributes on the apple side.
625+ *
626+ * @param string $attributesType
627+ * @return Payload
628+ */
629+ public function setAttributesType (string $ attributesType ): self
630+ {
631+ $ this ->attributesType = $ attributesType ;
632+
633+ return $ this ;
634+ }
635+
636+ /**
637+ * Get attributes type for Payload.
638+ *
639+ * @return string|null
640+ */
641+ public function getAttributesType (): string |null
642+ {
643+ return $ this ->attributesType ;
644+ }
645+
646+ /**
647+ * Add an attribute to the payload.
648+ *
649+ * @param string $key
650+ * @param mixed $value
651+ * @return Payload
652+ */
653+ public function addAttribute (string $ key , mixed $ value ): Payload
654+ {
655+ $ this ->attributes [$ key ] = $ value ;
656+
657+ return $ this ;
658+ }
659+
660+ /**
661+ * Add an array of attributes to the payload.
662+ *
663+ * @param array $attributes
664+ * @return Payload
665+ */
666+ public function addAttributes (array $ attributes ): Payload
667+ {
668+ $ this ->attributes = array_merge ($ this ->attributes , $ attributes );
669+
670+ return $ this ;
671+ }
672+
673+ /**
674+ * Get Attributes
675+ *
676+ * @return array
677+ */
678+ public function getAttributes (): array
679+ {
680+ return $ this ->attributes ;
681+ }
682+
683+ public function setDismissalDate (int $ value ): Payload
684+ {
685+ $ this ->dismissalDate = $ value ;
686+
687+ return $ this ;
688+ }
689+
690+ public function getDismissalDate (): int |null
691+ {
692+ return $ this ->dismissalDate ;
693+ }
694+
598695 /**
599696 * Convert Payload to JSON.
600697 *
@@ -688,6 +785,15 @@ public function jsonSerialize(): array
688785 $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_RELEVANCE_SCORE_KEY } = $ this ->relevanceScore ;
689786 }
690787
788+ if ($ this ->dismissalDate ) {
789+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_DISMISSAL_DATE_KEY } = (int ) $ this ->getDismissalDate ();
790+ }
791+
792+ if ($ this ->attributesType ) {
793+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_ATTRIBUTES_TYPE_KEY } = $ this ->attributesType ;
794+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_ATTRIBUTES_KEY } = $ this ->attributes ;
795+ }
796+
691797 return $ payload ;
692798 }
693799
0 commit comments