@@ -42,6 +42,11 @@ class Payload implements \JsonSerializable
4242 const PAYLOAD_CATEGORY_KEY = 'category ' ;
4343 const PAYLOAD_THREAD_ID_KEY = 'thread-id ' ;
4444 const PAYLOAD_URL_ARGS_KEY = 'url-args ' ;
45+ const PAYLOAD_TIMESTAMP_KEY = 'timestamp ' ;
46+ const PAYLOAD_EVENT_KEY = 'event ' ;
47+ const PAYLOAD_RELEVANCE_SCORE_KEY = 'relevance-score ' ;
48+ const PAYLOAD_STALE_DATE_KEY = 'stale-date ' ;
49+ const PAYLOAD_CONTENT_STATE_KEY = 'content-state ' ;
4550
4651 const PAYLOAD_HTTP2_REGULAR_NOTIFICATION_MAXIMUM_SIZE = 4096 ;
4752 const PAYLOAD_HTTP2_VOIP_NOTIFICATION_MAXIMUM_SIZE = 5120 ;
@@ -128,6 +133,42 @@ class Payload implements \JsonSerializable
128133 */
129134 private $ pushType ;
130135
136+ /**
137+ * Relevance score
138+ *
139+ * @var double
140+ */
141+ private $ relevanceScore ;
142+
143+ /**
144+ * Stale date
145+ *
146+ * @var double
147+ */
148+ private $ staleDate ;
149+
150+ /**
151+ * Timestamp
152+ *
153+ * @var double
154+ */
155+ private $ timestamp ;
156+
157+ /**
158+ * Event
159+ *
160+ * @var string
161+ */
162+ private $ event ;
163+
164+
165+ /**
166+ * Content state
167+ *
168+ * @var array
169+ */
170+ private $ contentState ;
171+
131172 protected function __construct ()
132173 {
133174 }
@@ -381,7 +422,7 @@ public function setCustomValue(string $key, $value): Payload
381422
382423 return $ this ;
383424 }
384-
425+
385426 /**
386427 * Merges custom value for Payload.
387428 *
@@ -438,6 +479,122 @@ public function getPushType()
438479 return $ this ->pushType ;
439480 }
440481
482+ /**
483+ * Set relevance score for Payload.
484+ *
485+ * @param double $relevanceScore
486+ * @return Payload
487+ */
488+ public function setRelevanceScore ($ relevanceScore )
489+ {
490+ $ this ->relevanceScore = $ relevanceScore ;
491+
492+ return $ this ;
493+ }
494+
495+ /**
496+ * Get relevance score for Payload.
497+ *
498+ * @return double
499+ */
500+ public function getRelevanceScore ()
501+ {
502+ return $ this ->relevanceScore ;
503+ }
504+
505+ /**
506+ * Set stale date for Payload.
507+ *
508+ * @param double $staleDate
509+ * @return Payload
510+ */
511+ public function setStaleDate ($ staleDate )
512+ {
513+ $ this ->staleDate = $ staleDate ;
514+
515+ return $ this ;
516+ }
517+
518+ /**
519+ * Get stale date for Payload.
520+ *
521+ * @return double
522+ */
523+ public function getStaleDate ()
524+ {
525+ return $ this ->staleDate ;
526+ }
527+
528+ /**
529+ * Set timestamp for Payload.
530+ *
531+ * @param double $timestamp
532+ * @return Payload
533+ */
534+ public function setTimestamp ($ timestamp )
535+ {
536+ $ this ->timestamp = $ timestamp ;
537+
538+ return $ this ;
539+ }
540+
541+ /**
542+ * Get timestamp for Payload.
543+ *
544+ * @return double
545+ */
546+ public function getTimestamp ()
547+ {
548+ return $ this ->timestamp ;
549+ }
550+
551+ /**
552+ * Set content-state for Payload.
553+ *
554+ * @param array $contentState
555+ * @return Payload
556+ */
557+
558+ public function setContentState ($ contentState )
559+ {
560+ $ this ->contentState = $ contentState ;
561+
562+ return $ this ;
563+ }
564+
565+ /**
566+ * Get content-state for Payload.
567+ *
568+ * @return array
569+ */
570+ public function getContentState ()
571+ {
572+ return $ this ->contentState ;
573+ }
574+
575+ /**
576+ * Set event for Payload.
577+ *
578+ * @param string $event
579+ * @return Payload
580+ */
581+ public function setEvent ($ event )
582+ {
583+ $ this ->event = $ event ;
584+
585+ return $ this ;
586+ }
587+
588+ /**
589+ * Get event for Payload.
590+ *
591+ * @return string
592+ */
593+ public function getEvent ()
594+ {
595+ return $ this ->event ;
596+ }
597+
441598 /**
442599 * Convert Payload to JSON.
443600 *
@@ -511,6 +668,26 @@ public function jsonSerialize(): array
511668 $ payload = array_merge ($ payload , $ this ->customValues );
512669 }
513670
671+ if (is_countable ($ this ->contentState ) && count ($ this ->contentState )) {
672+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_CONTENT_STATE_KEY } = $ this ->contentState ;
673+ }
674+
675+ if (is_string ($ this ->event )) {
676+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_EVENT_KEY } = $ this ->event ;
677+ }
678+
679+ if (is_double ($ this ->staleDate )) {
680+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_STALE_DATE_KEY } = $ this ->staleDate ;
681+ }
682+
683+ if (is_double ($ this ->timestamp )) {
684+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_TIMESTAMP_KEY } = $ this ->timestamp ;
685+ }
686+
687+ if (is_double ($ this ->relevanceScore )) {
688+ $ payload [self ::PAYLOAD_ROOT_KEY ]->{self ::PAYLOAD_RELEVANCE_SCORE_KEY } = $ this ->relevanceScore ;
689+ }
690+
514691 return $ payload ;
515692 }
516693
0 commit comments